加入收藏 | 设为首页 | 会员中心 | 我要投稿 鄂州站长网 (https://www.0711zz.com/)- 数据分析、网络、云渲染、应用安全、大数据!
当前位置: 首页 > 数据库 > MySql > 正文

如何获取mysql中缺少行的表

发布时间:2020-12-15 15:38:14 所属栏目: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

(编辑:鄂州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读