简体   繁体   English

如何从SQL Server 2000中的多个表中获取不同的行

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

I have 3 tables. 我有3张桌子。 I want to combine these three tables and I need distinct rows only in SQL Server 2000 我想组合这三个表,我只需要SQL Server 2000中的不同行

For example: 例如:

Table A 表A.

id
--
1  
2  
3  

Table B 表B.

id
--
2  
3  
4  

Table C 表C.

id
--
2  
3  
5  
6  

The results I want is: 我想要的结果是:

id
--
1  
2  
3  
4  
5  
6  

Any suggestion would be helpful ... 任何建议都会有所帮助......

Use UNION (without ALL ), something like this: 使用UNION (不包括ALL ),如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM