比较两个结果集或表中的值 [英] compare values from two result sets or tables
问题描述
大家好,
我一直试图从表A中获取与表B不匹配的记录。 这里棘手的是这些表没有共同的id,我已经使用所有其他四列的所有四列进行评估。 EG
我希望A中的字段不在B
我应该得到:1,2,4,1和8,8,8,8
如果我想做相反的事情,从B获取不在A
的记录我应该得到:4,3,2,1和7,7,7,7
---------------------- --------------------
有关如何使用T-SQL执行此操作的任何想法?我已经尝试过,但没有得到任何有意义的东西。
提前致谢!!!
您好
此处是代码,
SELECT * FROM TableA
EXCEPT
SELECT * FROM TableB
////////////////////////////////////////////
SELECT * FROM TableB
EXCEPT
SELECT * FROM TableA输出:
由于
Hello all,
i've been trying to get the records from table A that do not match with table B. the tricky thing here is that these tables do not have a common id, i have evaluate using all four columns against all the other four columns . E.G.
I want the fields from A that are not in B
i should get: 1, 2, 4, 1 and 8,8,8,8
and if i want to do the opposite, getting records from B that are not in A
i should get: 4,3,2,1 and 7,7,7,7
------------------------------------------
Any idea on how to do this with T-SQL ? i've tried except and did not get anything that made sense.
Thanks in advance!!!
Hi
Here is the code,
SELECT * FROM TableA EXCEPT SELECT * FROM TableB ////////////////////////////////////////////
SELECT * FROM TableB EXCEPT SELECT * FROM TableA
Output:
Thanks
这篇关于比较两个结果集或表中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!