select a,b,c,case when a=1 then 5 when a=2 then 6 end as d from some_table where d=6
实际的case语句真的很复杂,所以我试图避免在where子句中重复它有没有办法做到这一点?
(我认为MysqL使用“有d = 6”的技巧).
select a,c FROM( select a,case when a=1 then 5 when a=2 then 6 end as d from some_table ) AS t where d=6