SQL多表连接查询,请教大神如何操作

山狮 2016-11-03 10:59:19
交接单(其中matioid为两表链接主键)
Prodinout:
matioid (流水单号) deliverdeptid='10706'(交接的一个类型)
Prodinoutlist :
matioid (流水单号) handlsh(手工票号) mpsid(生产单号)


票飞单:
Feizailist :
mpsid(生产单号) handlsh(手工票号) 其他字段

注意:hanlsh mpsid 组合是唯一记录

如何SQL实现:
查询 票飞单 中没 交接的记录。
...全文
264 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
--小F-- 2016-11-03
  • 打赏
  • 举报
回复
;with cte as 
(
select b.handlsh,b.mpsid from Prodinout as a inner join Prodinoutlist as b on a.matioid=b.matioid
)
select * from Feizailist as  a where not exists(select 1 from cte where handlsh=a.handlsh and mpsid=a.mpsid)

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧