在 Oracle SQL 中,不接受此语法,返回ORA-00920:无效的关系运算符
select name
from employees
where (emp_id, dept_id) in (1 , 100)
or (emp_id, dept_id) in (2, 200)
order by emp_id;
虽然这个语法看起来完全有效(注意双括号)
select name
from employees
where (emp_id, dept_id) in ((1 , 100))
or (emp_id, dept_id) in ((2, 200))
order by emp_id;
您能解释一下原因吗?我在 Oracle 文档中没有找到任何对此语法的引用。
最佳答案
我想你想要:
select name
from employees
where (emp_id, dept_id) in ((1, 100), (2, 200))
order by emp_id;
问题是您正在比较元组。元组需要用自己的括号括起来。
关于sql - 解释 Oracle SQL 的语法 where ('a' ,'b' ) in ( ('x' , 'y' )),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45292968/