首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

exists用法

2014-01-28 
我想查找表A的servnum字段,并且表A中的account_id字段和表B的account_id字段相等,并且表B的acct_type的值为

我想查找表A的servnum字段,并且表A中的account_id字段和表B的account_id字段相等,并且表B的acct_type的值为200
开始写了几个SQL语句,查询效果不理想
select servnum from A a,B b where a.account_id = b.account_id and b.acct_type = 200;

select servnum from A where account_id in (select account_id from B where
acct_type = 200);

当我用exists查询时,
应该怎么写呢?exists并没有指定表A的哪个字段在表B的哪个字段存在啊 

请教exists用法
 

------解决方法--------------------------------------------------------
select servnum from A where exists (select account_id from B where
acct_type = 200 and account_id = account_id);

        

热点排行