在表A中查找表B中不存在的记录!!(如字段name)

dgnApo 2003-12-01 10:07:13
该怎么写sql语句?
name是主键
...全文
79 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dgnApo 2003-12-01
  • 打赏
  • 举报
回复
我要实现和in的概念相反的功能的sql语句,该怎么写?
pengdali 2003-12-01
  • 打赏
  • 举报
回复
光用:
select * from a where [name] not in (select [name] from b )
如果b表的name有null值是会错的。
pengdali 2003-12-01
  • 打赏
  • 举报
回复
select * from a where name not in (select name from b where name is not null)
sunsunup 2003-12-01
  • 打赏
  • 举报
回复
select * from a where [name] not in (select [name] from b )
sunshareforever 2003-12-01
  • 打赏
  • 举报
回复
select * from a where a.name not in (select name from b )


victorycyz 2003-12-01
  • 打赏
  • 举报
回复
select * from A left join B on A.name=B.name where B.name is null

22,300

社区成员

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

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