MySQL查询json类型的字段是否为空

MySQL 新版本加入了对json字段的支持,目标筛选json类型出来为空的行。

-- 长度判断
select colname from tablename where id<10 and json_length(`colname`)=0;

-- 取出第一个元素判断
select colname from tablename where id<10 and JSON_EXTRACT(`colname`, '$[0]') is not null;

 

posted @ 2022-10-26 17:27  飞扬92  阅读(1786)  评论(0编辑  收藏  举报