我一直在尝试构造一个如下所示的条件IN,但这给出了scalar subquery produced more than one element错误。我应该如何处理这种类型的查询呢?这些表是不相关的。
select * from my_table
where my_table.my_col in (
case
when 1 = 1
then (select my_col from my_other_table_1)
else (select my_col from my_other_table_2)
end
)发布于 2020-09-16 15:42:15
试试下面这个-
select * from my_table
where my_table.my_col in (
SELECT
case
when 1 = 1 then my_col_1
else my_col_2
END
from my_other_table
)因为你的其他表是不相关的,你可以尝试下面的逻辑-
select * from my_table
where
(1=1 and my_col IN (select my_col_1 from my_other_table_01)
OR
(3=3 and my_col IN (select my_col_2 from my_other_table_02)https://stackoverflow.com/questions/63915181
复制相似问题