Link to home
Start Free TrialLog in
Avatar of nurbek
nurbek

asked on

Join two tables and select distinct

Hi All,

I have to tables

users table  -- user_email(field)
aaa@aa.com
bbb@cc.com
ccc@cc.com
test@test.com

mail_list table -- email(field)
aaa@aa.com
ddd@fff.com
sss@qq.com
test@test.com

output should be like this (distinct_email) ordered
aaa@aa.com
bbb@cc.com
ccc@cc.com
ddd@fff.com
sss@qq.com
test@test.com

I want to join two tables, and select disctinc email adres

thanks in advance
Nurbek

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

select user_email from users
UNION
select email from mail_list
order by 1
Avatar of nurbek
nurbek

ASKER

thanks for your quick reply

It works,

could you please explain order by 1?

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nurbek

ASKER

thanks!