Reputation: 735
I need to do the following :
select table1.abc from table1 where col1 = ? and col2 = ?
The problem here is i need to get data from this table for 3 sets of (col1, col2). I don't want to execute the same query 3 for different parameters.
Also i want to have the result set of the executed query containing 3 columns of data (1 for each set of col1,col2).
Let me know if any further details are reqd.
Upvotes: 0
Views: 758
Reputation: 254
You can use OR clause with 3 sets having different parameter set
select table1.abc from table1 where (col1 = ? and col2 = ?)
OR (col1 = ? and col2 = ?) OR (col1 = ? and col2 = ?)
Upvotes: 1
Reputation: 116458
You can just use subselects if there's only one result for your query:
select (select table1.abc from table1 where col1 = ? and col2 = ?),
(select table1.abc from table1 where col1 = ? and col2 = ?),
(select table1.abc from table1 where col1 = ? and col2 = ?)
from table1
limit 1
Upvotes: 1