Home  >  Article  >  Database  >  How to query the value of json in mysql

How to query the value of json in mysql

藏色散人
藏色散人Original
2020-10-23 09:54:586281browse

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 表名;

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;

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!

Statement:
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