比较MySql表(Compare MySql Tables)
mysql
我有2个表,每个表都有数字:
对于expamle - >
表1:1 2 3 4 5
表2:5 3 1
我正在尝试编写一个查询,显示表1中的任何值,但不在表2中(反之亦然)。 数字可以是任何顺序,都是主键。
I have 2 tables with numbers in each:
For expamle ->
Table 1: 1 2 3 4 5
Table 2: 5 3 1
I'm trying to write a query that displays any values that are in table 1 but aren't in table 2 (and the other way round). The numbers could be in any order and are both primary keys.
最满意答案
使用WHERE NOT EXISTS两个单独的查询,然后将它们的输出与UNION 。
Make two separate queries using WHERE NOT EXISTS, then combine their output with UNION.
更多推荐
发布评论