首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

如何搜索两个表之间的不同单号

2013-03-10 
怎么搜索两个表之间的不同单号tsms_export,tsms_exportdetail这两个表,都有单号i_no这一列,但是有一些单号

怎么搜索两个表之间的不同单号
tsms_export,tsms_exportdetail这两个表,都有单号i_no这一列,但是有一些单号tsms_export里边查不到,tsms_exportdetail里边能查到,用什么能查出这些单号来呢?请教
[解决办法]

select i_no from tsms_exportdetail a where not exists(select 1 from tsms_export b where a.i_no=b.i_no)

[解决办法]
主单跟详单呗

select * from tsms_export a right join
(select distinct i_no from tsms_exportdetail) b on a.i_no=b.i_no
where a.i_no is null
[解决办法]
select * from tsms_exportdetail a
where not exists (
select 1 from tsms_export
where i_no = a.i_no
)

热点排行