选择 IN 参数中的 Oracle 多个字段
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7167346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle multiple fields in Select IN Parameter
提问by priceline
Select * FROM STUDENT
WHERE (student.course, student.major) IN (SELECT schedule.course, schedule.major
FROM schedule)
What if i have to provide static values, what would be the query like? Because I am passing the SQL from a middle layer based on input parameters.
如果我必须提供静态值怎么办,查询会是什么样的?因为我是根据输入参数从中间层传递 SQL。
Edit: I am looking to search based on multiple sets of values. For ex.
编辑:我希望根据多组值进行搜索。例如。
Select * FROM STUDENT
WHERE (student.course, student.major) IN
(('MBA', 'Computers'), ('BA', 'Computers'))
回答by Henry Collingridge
I'm pretty sure you can use this:
我很确定你可以使用这个:
Select * FROM STUDENT
WHERE (student.course, student.major)
IN (SELECT 'MBA', 'Computers' from DUAL
union SELECT 'BA', 'Computers' from DUAL);
:D
:D
回答by beny23
Do you mean (or am I misunderstanding something about hardcoding?):
你的意思是(还是我误解了硬编码?):
select * from student
where course = 'DB101'
and major = 'MyMajor'