mysql case ... when语句的几个用法
一般情况下,case ...when都用在select语句中,不过可以在其他子句中使用
1 在order by子句中进行自定义排序
set @role_id=1;set @dept_id=2;select * from 20130225work w,20130225role rwhere r.id=@role_id and w.role_id=r.idand (case need_check when 1 then dep_id=@dept_idelse 1=1end)
case when也能在group by语句中出现,只是不知道能有啥作用.
其实我最希望它能出现在from语句中,就能动态指定from的表.