SQL How to replace values of select return?

前端 未结 7 1170
无人共我
无人共我 2020-12-04 18:02

In my database (MySQL) table, has a column with 1 and 0 for represent true and false respectively.

But in S

相关标签:
7条回答
  • 2020-12-04 18:36

    If you want the column as string values, then:

    SELECT id, name, CASE WHEN hide = 0 THEN 'false' ELSE 'true' END AS hide
      FROM anonymous_table
    

    If the DBMS supports BOOLEAN, you can use instead:

    SELECT id, name, CASE WHEN hide = 0 THEN false ELSE true END AS hide
      FROM anonymous_table
    

    That's the same except that the quotes around the names false and true were removed.

    0 讨论(0)
提交回复
热议问题