如何比较具有相同值的多个列(Oracle SQL)
我需要在WHERE子句中不使用multiple AND condition的情况下,将一个表的多个值与同一组值在单次快照中进行比较。请让我知道有什么方法可以做到这一点 代码: 或加入如何比较具有相同值的多个列(Oracle SQL),sql,oracle,Sql,Oracle,我需要在WHERE子句中不使用multiple AND condition的情况下,将一个表的多个值与同一组值在单次快照中进行比较。请让我知道有什么方法可以做到这一点 代码: 或加入 Select count(1) from test t1 join test t2 on( sys_id= pre_sys_id1 and sys_id= pre_sys_id2 and sys_id= pre_sys_id3 and sys_id= pre_sys_id4) where t2.auto_id
Select count(1)
from test t1
join test t2 on( sys_id= pre_sys_id1 and sys_id= pre_sys_id2 and sys_id= pre_sys_id3 and sys_id= pre_sys_id4)
where t2.auto_id = 10 ;
或加入
Select count(1)
from test t1
join test t2 on( sys_id= pre_sys_id1 and sys_id= pre_sys_id2 and sys_id= pre_sys_id3 and sys_id= pre_sys_id4)
where t2.auto_id = 10 ;
您可以尝试:
select count(1)
from test
where (pre_sys_id1, pre_sys_id2, pre_sys_id3, pre_sys_id4)
in (select sys_id, sys_id, sys_id, sys_id from test where auto_id = 10)
您可以尝试:
select count(1)
from test
where (pre_sys_id1, pre_sys_id2, pre_sys_id3, pre_sys_id4)
in (select sys_id, sys_id, sys_id, sys_id from test where auto_id = 10)
您的输出应该是什么样子?您的输出应该是什么样子?如果从测试中选择sys\u id,其中auto\u id=10返回多行怎么办?将引发异常,单行子查询返回多行。“全部/部分”构造仅适用于标量值。一个\u值=,所有/某些值集如果从测试中选择sys\u id,其中auto\u id=10返回多行怎么办?将引发异常,单行子查询返回多行。“全部/部分”构造仅适用于标量值。一个值=,所有/某些值集