如何获取mysql中缺少行的表

我有两个mysql表TABLEAcolA1 colA2 1 whatever 2 whatever 3 whatever 4 whatever 5 whatever 6 whatever 第二个表基本上是从tableA派生的,但删除了一些行tableB的colB1 colB2

我有两个mysql表

TABLEA

colA1   colA2
1       whatever
2       whatever
3       whatever
4       whatever
5       whatever
6       whatever

第二个表基本上是从tableA派生的,但删除了一些行

tableB的

colB1    colB2
1       whatever
2       whatever
4       whatever
6       whatever

如何编写查询以从上面的两个表中获取缺失行的表

colC1   colC2
3      whatever
5      whatever

最佳答案

SELECT t1.*
FROM TableA t1 LEFT JOIN
     TableB t2 ON t1.ID = t2.ID
WHERE t2.ID IS NULL

作者: dawei

【声明】:西安站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部