Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Join two tables and select distinct

Posted on 2006-05-23
4
Medium Priority
?
820 Views
Last Modified: 2012-06-22
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

0
Comment
Question by:nurbek
  • 2
  • 2
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16740431
select user_email from users
UNION
select email from mail_list
order by 1
0
 
LVL 13

Author Comment

by:nurbek
ID: 16740462
thanks for your quick reply

It works,

could you please explain order by 1?

0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1600 total points
ID: 16740499
the order by 1 will order by the first field in the select list, hence your email field
0
 
LVL 13

Author Comment

by:nurbek
ID: 16740505
thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question