0

この「単一行のサブクエリが複数の行を返す」というエラーが発生しました

そして私のクエリは

Select contact_ID from contact where (

Select b.Contact_ID from company a, contact b where a.Company_ID =  b.Company_ID 
and a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
and a.CREATED_DATE >= '01-Jun-2013') =
(
Select b.Contact_ID from company a, contact b where a.Company_ID =  b.Company_ID 
and a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
and a.CREATED_DATE < '01-Jun-2013');

なぜこれが機能しないのかわかりません。私を助けてください

4

3 に答える 3

1

これを試して

    Select contact_ID from contact where Contact_ID in 
        (
         Select b.Contact_ID from company a 
         inner join contact b 
         on  a.Company_ID =  b.Company_ID 
         where a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
         and a.CREATED_DATE >= '01-Jun-2013' 
         ) ;

編集:

IN句なしでより簡単。

     Select b.Contact_ID from company a 
     inner join contact b 
     on  a.Company_ID =  b.Company_ID 
     where a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
     and a.CREATED_DATE >= '01-Jun-2013' ;
于 2013-09-16T19:55:13.473 に答える
0

これを試して:

サブセレクトを削除し、ユニオンに置き換えました。

Select b.Contact_ID 
from company a, contact b 
where a.Company_ID =  b.Company_ID 
and a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
and a.CREATED_DATE >= '01-Jun-2013'
union
Select b.Contact_ID 
from company a, contact b 
where a.Company_ID =  b.Company_ID 
and a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
and a.CREATED_DATE < '01-Jun-2013');
于 2013-09-16T20:19:41.263 に答える
0

これを試して

Select contact_ID 
from contact 
where (
Select b.Contact_ID 
from company a, contact b 
where a.Company_ID =  b.Company_ID 
and a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
and a.CREATED_DATE >= '01-Jun-2013') IN
(
Select b.Contact_ID 
from company a, contact b 
where a.Company_ID =  b.Company_ID 
and a.IS_ACTIVE <> 'N' and b.IS_ACTIVE <> 'N'
and a.CREATED_DATE < '01-Jun-2013');
于 2013-09-16T19:53:16.300 に答える