美文网首页
mysql的json查询、coalesce函数、case whe

mysql的json查询、coalesce函数、case whe

作者: 陈追风 | 来源:发表于2019-04-23 11:35 被阅读0次

mysql json 查询结果去掉双引号 “”

select json->'$.attr' from table;

select JSON_UNQUOTE(json_extract(json,'$.attr')) from table;

Mysql的coalesce函数

作用是将返回传入的参数中第一个非null的值

SELECT COALESCE(NULL, NULL, 1);
-- Return 1

MySQL的case when then

SQL> select u.id,u.name,
   (case u.sex
     when 1 then '男'
     when 2 then '女'
     else '空的'
     end
    )性别
 from users u;

相关文章

网友评论

      本文标题:mysql的json查询、coalesce函数、case whe

      本文链接:https://www.haomeiwen.com/subject/xetvgqtx.html