读书人

exists用法

发布时间: 2014-01-28 21:24:17 作者: rapoo

我想查找表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);

        

读书人网 >oracle

热点推荐