记 Mysql 部分用法
JSON
1、查询数组中对象
JSON_CONTAINS
用法
1 | select * from circulation |
2、Json 字符串转化为 Json 对象
CONVERT
用法
1 | select CONVERT('{"mail": "amy@gmail.com", "name": "Amy"}',JSON) |
3、元素转化为数组
JSON_ARRAY
用法
1 | SELECT JSON_ARRAY(1, "abc", NULL, TRUE, CURTIME()) |
4、数组中查询元素
JSON_CONTAINS + JSON_ARRAY
用法
1 | select JSON_CONTAINS(JSON_ARRAY(1,2,3,4,5,6),'6') |
5、数组模糊查询
JSON_SEARCH用法
1 | select * from table where JSON_SEARCH(profiles, 'all', 'sales%') is not null |
常规
1、查询重复记录
1 | select * from merchant |