我有一个包含2列的表,其中一列是唯一的。我想从表中获取记录,如下所示,我想从我的SQL开发人员中查询以从表中获取记录,其中事务ID = 195865487、201263012,事务顺序为 195865487为1,4,5,6,7,201263012为2,3,4,5,6,7。
new
答案 0 :(得分:1)
构造如下的where
条件:
select * from t
where (transaction_id = 195865487 and transaction_seq in (1,4,5,6,7))
or (transaction_id = 201263012 and transaction_seq in (2,3,4,5,6,7))
答案 1 :(得分:0)
这是您需要的吗?
SELECT * FROM some_table
WHERE transaction_id IN (195865487, 201263012)
AND (transaction_sequence IN (1,4,5,6,7)
OR transaction_sequence IN (2,3,4,5,6,7))
答案 2 :(得分:0)
这将为您提供所需的结果
SELECT * FROM table
WHERE (transaction_id=195865487 AND transaction_seq IN (1,4,5,6,7))
OR (transaction_id=201263012 AND transaction_seq IN (2,3,4,5,6,7))