t3m_data表中的数据如下:
GZD_BH, NSRSBH, BH
'001', '43122741', '1'
'002', '43122742', '2'
'003', '43122743', '3'
'004', '43122744', '4'
'004', '43122741', '8'
'005', '43122745', '5'
'005', '43122741', '9'
'006', '43122746', '6'
'006', '43122741', '7'
t3m_zhgl_data表中数据如下:
GZD_BH, NSRSBH, DATA
'001', '43122741', '1'
'002', '43122742', '2'
'003', '43122743', '3'
'005', '43122745', '5'
select gzd_bh,nsrsbh from t3m_data a
where not exists
(
select gzd_bh,nsrsbh from t3m_zhgl_data b where a.gzd_bh=b.gzd_bh and a.nsrsbh=b.nsrsbh
)
运行结果:
gzd_bh, nsrsbh
'004', '43122744'
'006', '43122746'
'006', '43122741'
'004', '43122741'
'005', '43122741'
本文通过一个具体的例子展示了如何使用SQL的NOT EXISTS子句来找出两个表中不匹配的数据记录。通过对t3m_data表和t3m_zhgl_data表进行对比查询,详细解释了查询过程及结果。
67

被折叠的 条评论
为什么被折叠?



