Changing the projected value with MySQL
How to change the projected value fr开发者_StackOverflow中文版om select in MySQL? Is it possible with the following SQL?
SELECT IF(situation=0,1,0) FROM users;
Thanks in advance
You can use MySQL's CASE Statement.
SELECT CASE situation
WHEN 0 THEN 1
ELSE 0
END CASE
FROM users;
HQL also has the CASE expression. Check this link.
This depends highly on the DBMS.
You can use Oracle NVL or CASE as Marcelo suggests.
But I would go for a COALESCE SQL function.
http://www.1keydata.com/sql/sql-coalesce.html
加载中,请稍侯......
精彩评论