Vasu Shanmugam
Vasu Shanmugam

Reputation: 67

How to get distinct rows from multiple tables in SQL Server 2000

I have 3 tables. I want to combine these three tables and I need distinct rows only in SQL Server 2000

For example:

Table A

id
--
1  
2  
3  

Table B

id
--
2  
3  
4  

Table C

id
--
2  
3  
5  
6  

The results I want is:

id
--
1  
2  
3  
4  
5  
6  

Any suggestion would be helpful ...

Upvotes: 1

Views: 1389

Answers (1)

Mahmoud Gamal
Mahmoud Gamal

Reputation: 79969

Use UNION (without ALL), something like this:

SELECT id 
FROM Table1
UNION
SELECT id
FROM Table2
UNION
SELECT id
FROM Table3

Upvotes: 4

Related Questions