比较MySql表(Compare MySql Tables)

编程入门 行业动态 更新时间:2024-10-28 08:19:49
比较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.

更多推荐

本文发布于:2023-04-27 15:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1327333.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MySql   Compare   Tables

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!