$q="SELECT DISTINCT
t1.un_email,t6.email
FROM
sisters_7sisters.tbl_unsubscribe as t1,
sisters_7sisters.tbl_uptade_list as t6";
I write a query like above I need to retrieve all the unique emails from the tables But it gives me pair of some results which are not unique ..I tried to get the email only once from these tables.
It would be better to use a join to join those two tables and select the distinct email
The distinct you are using, is only applied to each column of the result and not both at the same time.
It you are not joing them and you do not have any where
clause. Then you might be fine with this solution (No duplicate emails):
SELECT
t1.un_email AS email
FROM
sisters_7sisters.tbl_unsubscribe as t1
UNION
SELECT
t6.email
FROM
sisters_7sisters.tbl_uptade_list as t6
Or you can use a UNION ALL
. This will return the duplicates:
SELECT
t1.un_email AS email
FROM
sisters_7sisters.tbl_unsubscribe as t1
UNION
SELECT
t6.email
FROM
sisters_7sisters.tbl_uptade_list as t6
Ithink you have forgot Join ocndition
when you use
select * from table1,table2
it will create a cartisian product
if table1 as
1
2
3
and table2 has
4
5
6
as their data.
cartesian product will be
1 4
1 5
1 6
2 4
2 5
2 6
3 4
3 5
3 6
to remove this unnecesary fields you have to Join