【发布时间】:2013-07-26 08:51:33
【问题描述】:
我有以下问题
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 包含列 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')
我的问题是,当我使用第二个查询时,它没有给出任何结果。我知道子查询将返回与外部查询中的行匹配的结果。但它显示了空的结果集。
我正在使用 oracle 11g
谁能帮帮我..提前谢谢大家。
【问题讨论】:
标签: sql database oracle oracle11g