日期:2014-05-16  浏览次数:20840 次

SQL,标题太短没法描述~~T T
A,B两个表字段不同,但是B表中含有一个connid字段对应与A表中的id,怎么查出在A中并且id没有在表B中的记录....好乱~~~

------解决方案--------------------
select  id  from  a  
where not exists(select  1 from  b
where  b.id=a.id)
------解决方案--------------------
真替你捉急 select * from a where not exists (select 1 from b where b.connid = a.id)
------解决方案--------------------

 select a.* from A a where not exists 
 (select 1 from B b where b.connid = a.id)

------解决方案--------------------
引用:
Quote: 引用:

真替你捉急 select * from a where not exists (select 1 from b where b.connid = a.id)
只用过最简单的HQL嘿,这里的1指什么,我用*也行
恩 都是可以的