2
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.

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'))
5
  • What static values, exactly, are you trying to handle? Are you trying to send multiple values for a single column (i.e. an array of majors)? Or are you trying to send static values for multiple columns (i.e. a course and a major)? Commented Aug 23, 2011 at 20:54
  • You are looking to replace (SELECT schedule.course, schedule.major FROM schedule) with a static/parameter list? Commented Aug 23, 2011 at 20:54
  • Cade, yes, I am looking to replace with the static parameter list (pass 1 or more sets of data). Commented Aug 23, 2011 at 21:45
  • @priceline - OK. And what is the "middle layer" that you are passing the data from? Commented Aug 24, 2011 at 4:17
  • Your edit appears to be a query that should work just fine. Have you tried it? Commented Mar 15, 2012 at 10:53

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

Do you mean (or am I misunderstanding something about hardcoding?):

select * from student
 where course = 'DB101'
   and major = 'MyMajor'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.