如何在 1 个查询中组合 4 个查询? (甲骨文 SQL)

HOW CAN COMBINE 4 QUERY IN 1 QUERY ? (ORACLE SQL)

你好,我想合并查询。

select * 来自 table where code='?';

select * 来自 table where code='?'或代码='?';

select * 来自 table where code='?'或代码='?'或代码='?';

select * 来自 table where code='?'或代码='?'或代码='?'或代码='?';

我做了这 4 个查询,但我想将它们组合起来。我怎么可以?

并且代码有 4 个值,例如 1,2,3,4 请帮我! (我正在使用 Oracle 11,SQL 开发人员)

例如你可以使用 union all

select * from table where code='?';
union all
select * from table where code='?' or code='?';
union all
select * from table where code='?' or code='?' or code='?';
union all
select * from table where code='?' or code='?' or code='?' or code='?';

或者您可以使用 IN 运算符,例如

select * from table where code in ('?',?','?','?')

我不确定问题的措辞方式,但我认为您可能正在寻找 IN 陈述?

SELECT * FROM tablename WHERE code IN ('1' ,'2' ,'3' ,'4');

有关这方面的更多信息,请访问

https://docs.oracle.com/database/121/SQLRF/conditions014.htm