Wednesday, 28 August 2013

Using "WHERE" with a variable that has multiple values

Using "WHERE" with a variable that has multiple values

I want to know how to select columns from a table where another column has
several possible values. So, for example, this code will return Column X
from table 1 and Column B from Table 2 if Column G has the value given by
the input.
variable input varchar2(60);
exec :input := 'c';
Select Table1.x, Table2.b
FROM Table1, Table2
WHERE Table1.g = :input
What if instead, I wanted to return Column X from table 1 and Column B
from Table 2 if Column G had value "k" or "c" or "d" without doing
WHERE Table1.g = "k" or Table1.g = "c" or Table1.g = "d"
How do i define the input such that I get this effect?
Thank you!
I use: oracle 10g, PL/SQL

No comments:

Post a Comment