What is the best way to convert an int or null to boolean value in an SQL query?

前端 未结 10 1222
情话喂你
情话喂你 2021-02-06 21:07

What is the best way to convert an int or null to boolean value in an SQL query, such that:

  • Any non-null value is TRUE in the results
  • Any
10条回答
  •  醉梦人生
    2021-02-06 21:57

    Usually when use 1, it means is true and else in other case.

    So:

    SELECT  IsDefault = CASE WHEN IsDefault = 1 THEN 'true' ELSE 'false' END
    FROM table
    

提交回复
热议问题