库存表-出货表-求未出货的。

沐NeMo 2011-08-27 02:46:45
库存表A
关键字
lngItemID strItemName ...
货物ID

出货表C
lngItemID strItemName dblQTY..


找出未出货的货物,也就是找出没有在表C出现过的货物。
是不是用这句: select * from A where lngItemID not in ( select lngItemID from C) ?
还是要怎么写?
如果表C 几万个记录呢,有什么更好方法?
...全文
116 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
棉花棒棒糖 2011-08-29
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 nbdba 的回复:]
SQL code

select * from A where not EXISTS ( select 1 from C WHERE lngItemID = A.lngItemID)
[/Quote]
+
--小F-- 2011-08-27
  • 打赏
  • 举报
回复
select * from A where not exists ( select 1 from c where lngItemID = A.lngItemID)


select * from a where checksum(lngItemID) not in(select checksum(lngItemID) from c)
AcHerat 元老 2011-08-27
  • 打赏
  • 举报
回复
not exists

表连接找null的

select a.*
from a left join b on a.id = b.id
where b.id is null
NBDBA 2011-08-27
  • 打赏
  • 举报
回复
select * from A where not EXISTS ( select 1 from C WHERE lngItemID = A.lngItemID)

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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