从两个表中选择不同的值 [英] Selecting distinct values from two tables
问题描述
我有两个相当大的数据库(每个数据库有100万行)。两个表具有相同的结构。
如何检查列中的每个值在两个表中是否唯一?
是否存在来自tbl的 谢谢! 您可以在子查询中 类似的东西 I have two rather large databases (+1 million rows each). Both tables have the same structure. How can I check if each value in a column is unique across both tables? Is there a Thanks! You can Something like:
这篇关于从两个表中选择不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
SELECT COUNT(DISTINCT
col )
UNION
两个完整的集合,然后从中选择 DISTINCT col
。
SELECT DISTINCT col FROM(SELECT * FROM tbl1 UNION全部选择*来自tbl2)
SELECT COUNT(DISTINCT
col) FROM tbl
type of query that will consider BOTH tables?UNION
two full sets in a subquery and then select DISTINCT col
from that.SELECT DISTINCT col FROM (SELECT * FROM tbl1 UNION ALL SELECT * FROM tbl2)