首页 MySql 如何获取mysql中缺少行的表

如何获取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

本文来自网络,不代表青岛站长网立场。转载请注明出处: https://www.0532zz.com/html/shujuku/mysql/20201215/13867.html
上一篇
下一篇

作者: dawei

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

为您推荐

返回顶部