次のクエリがあります
select * from table_1
where Conditions in
(select case when check_condition = 'Y' then 'Condition_1'
else 'N/A' end as Check_condition
from table_2
WHERE id = 1122)
ここで、table_1 には次のように column の値が含まConditions
れます。条件_1,条件_2
これは正常に機能し、結果を返します。
句内で複数の選択ステートメントを使用したいin
ので、以下のようにしました。
select * from table_1
where Conditions in (
select ''''||
(select case when check_condition = 'Y' then 'Condition_1'
else 'N/A' end as Check_condition
from table_2
WHERE id = 1122)||''''||','''||
(select case when check_condition = 'Y' then 'Condition_2'
else 'N/A' end as Check_condition
from table_2 WHERE id = 1122)||''''
from dual
)
内部クエリ( in 句内)で、期待どおりの正しい結果が得られます-
'Condition_1','Condition_2'
親クエリにコピーして貼り付けると、正常に動作し、結果が表示されます。
select * from table_1 where Conditions in ('Condition_1','Condition_2')
私の問題は、2 番目のクエリを使用したときに結果が得られないことです。サブクエリは、外側のクエリの行と一致する必要がある結果を返すことを知っています。しかし、空の結果セットが表示されます。
私はオラクル11gを使用しています
誰でも私を助けてくれませんか.. よろしくお願いします。