Home > Database > Mysql Tutorial > body text

How to query the value of json in mysql

藏色散人
Release: 2020-10-23 09:54:58
Original
6294 people have browsed it

Mysql method to query the value of json: first open the command window; then execute the SQL statement "SELECT REPLACE(json_extract(push_data,'$.carRenewalInfoVo.licence')..." to query the value of json .

How to query the value of json in mysql

Recommended: "mysql video tutorial"

mysql finds a certain field in json

SELECT json_extract(字段名,'$.json结构') FROM 表名;
Copy after login

If there are double quotes in json, then the data taken out in this way will also have double quotes. To remove it, use the REPLACE function

For example:

ps_push_data table The data stored in the push_data field is: {"carRenewalInfoVo":{"licence":"Zhejiang AF55Z0"},"code":"1","msg":"success"}

Use sql

SELECT REPLACE(json_extract(push_data,'$.carRenewalInfoVo.licence'),'"','') FROM ps_push_data;
Copy after login

What is taken out is: Zhejiang AF55Z0

It is worth noting that only MySQL5.7 and above versions support the operation of json data

The above is the detailed content of How to query the value of json in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template