sql中,当x=0时ActionID在(1,2,3,4)中,当x=1时id在(1,2)中,当x=2时id在(3,4)中
如何在SQLWHERE子句中表示以下条件sql中,当x=0时ActionID在(1,2,3,4)中,当x=1时id在(1,2)中,当x=2时id在(3,4)中,sql,sql-server,tsql,Sql,Sql Server,Tsql,如何在SQLWHERE子句中表示以下条件 where id in Case x=0 then (1,2,3,4) case x=1 then (1,2) case x=2 then (3,4) ... WHERE (x=0 AND id IN (1,2,3,4)) OR (x=1 AND id IN (1,2)) OR (x=2 AND id IN (3,4))
where id in
Case x=0 then (1,2,3,4)
case x=1 then (1,2)
case x=2 then (3,4)
...
WHERE (x=0 AND id IN (1,2,3,4))
OR (x=1 AND id IN (1,2))
OR (x=2 AND id IN (3,4))