加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

如何获取mysql中缺少行的表

发布时间:2020-12-11 23:42:46 所属栏目:MySql教程 来源:网络整理
导读:我有两个mysql表 TABLEA colA1 colA21 whatever2 whatever3 whatever4 whatever5 whatever6 whatever 第二个表基本上是从tableA派生的,但删除了一些行 tableB的 colB1 colB21 whatever2 whatever4 whatever6 whatever 如何编写查询以从上面的两个表中获取缺

我有两个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

(编辑:李大同)

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

    推荐文章
      热点阅读