select CUS_ID,ACC_NBR from A where ACC_NBR not in (select distinct ACC_NBR from b)
1楼的select 1也是一个提高效率的做法,你的语句中用distinct会增加查询开销,降低查询效率
试试这个: select CUS_ID,ACC_NBR from A where not exists (select 1 from b where a.ACC_NBR = b.ACC_NBR )
select CUS_ID,ACC_NBR from A where not exists (select 1 from b where a.ACC_NBR = b.ACC_NBR )
[quote=引用 1 楼 yupeigu 的回复:] 试试这个: select CUS_ID,ACC_NBR from A where not exists (select 1 from b where a.ACC_NBR = b.ACC_NBR )
34,594
社区成员
254,589
社区内容
加载中
试试用AI创作助手写篇文章吧