0

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.

4

2 に答える 2

1

クエリの結果が 1 つしかない場合は、サブセレクトを使用できます。

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
于 2012-08-29T16:18:12.223 に答える
1

異なるパラメータ セットを持つ 3 つのセットで OR 句を使用できます

select table1.abc from table1 where (col1 = ? and col2 = ?)
OR (col1 = ? and col2 = ?) OR (col1 = ? and col2 = ?)
于 2012-08-29T16:46:27.217 に答える