我正在使用MySQL,并且想在SQL中执行一种三元语句,例如:
SELECT USER_ID, ((USER_ID = 1) ? 1 : 0) AS FIRST_USER FROM USER
结果将类似于:
USER_ID | FIRST_USER 1 | 1 2 | 0 3 | 0 etc.
如何做到这一点?
SELECT USER_ID, (CASE USER_ID WHEN 1 THEN 1 ELSE 0 END) as FIRST_USER FROM USER