gpt4 book ai didi

mysql - 多列 IN 子句

转载 作者:可可西里 更新时间:2023-11-01 07:47:35 28 4
gpt4 key购买 nike

有没有办法只使用一个使用多列 IN 子句的查询来实现以下联合查询?

而不是使用

select * 
from table_a
where field_a in (select field_1 from table_b)
union
select *
from table_a
where field_a in (select field_2 from table_b);

我想创建如下所示的内容:

select * 
from table_a
where field_a in (select field_1,field_2 from table_b) ;

最佳答案

最多只能将联合放在子查询中:

select * 
from table_a
where field_a in (select field_1 from table_b union select field_2 from table_b)

或者:

select * 
from table_a
where field_a in (select field_1 from table_b)
or field_a in ( select field_2 from table_b)

关于mysql - 多列 IN 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24985566/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com