标签: sql sql-server tsql
如何在sql where子句中表示以下条件?
where id in Case x=0 then (1,2,3,4) case x=1 then (1,2) case x=2 then (3,4)
答案 0 :(得分:10)
... 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))