MYSQL - How to find the result of two tables?


I am not good with mysql so need to know how to find result from two tables.

Let's say I have two tables:

Brand table:

Id  Email           Password
--  -----           --------
1   [email protected]  12345678

Facebook table:

Id  Email               Password
--  -----               --------
1   [email protected]  12345678

Now I want to find this email address [email protected] from both table and want to get Email & Password from result.

Any Idea how to do this?


SELECT * FROM brand_table
select * from facebook_table

UNION will bring distinct records.

If you use union all, it will bring duplicates as well.

In your case:

SELECT * FROM brand_table where email ='[email protected]'
union all
select * from facebook_table where email ='[email protected]'