开发者

Changing the projected value with MySQL

开发者 https://www.devze.com 2023-04-08 16:39 出处:网络
How to change the projected value fr开发者_StackOverflow中文版om select in MySQL? Is it possible with the following SQL?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号