How to create a JSON object in MySql with a boolean value?

后端 未结 4 1475
星月不相逢
星月不相逢 2021-01-16 06:09

I would like my MySql query to return a JSON object that looks as follows:

{\"name\": \"Piotr\", \"likesMysql\": true}

This seems to be wor

4条回答
  •  天命终不由人
    2021-01-16 07:03

    Simply go with following,

    SELECT json_object( 'name', 'Piotr', 'likesMysql', if(5 MOD 2 = 0, TRUE, FALSE) is true )

    Hope you get desired result with this :)

提交回复
热议问题