我正在尝试:
select
case when exists (id) then id else 'n/a' end as id
from mytable
where id="35";
但是我弹出了一些错误或其他错误。我做错了什么,还是这根本不可行?
check the manual that corresponds to your MySQL server version for the right syntax to use near 'id) then id else 'n/a' end as id from mytable where id="35"' at line 2 */
最佳答案
select case when id = 35 then id else 'n/a' end as id
from mytable
order by case when id = 35 then 1 else 2 end
limit 1
SQLFiddle demo
关于mysql - 无法使用 case 且存在于 sql 语句中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19007995/