Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何使用MariaDB从JSON列中提取值,因为这不是JSON字段中的精确值?_Sql_Json_Database_Mariadb - Fatal编程技术网

Sql 如何使用MariaDB从JSON列中提取值,因为这不是JSON字段中的精确值?

Sql 如何使用MariaDB从JSON列中提取值,因为这不是JSON字段中的精确值?,sql,json,database,mariadb,Sql,Json,Database,Mariadb,我需要用MariaDB从JSON字符串中提取一个字段,并在该字段中搜索特定模式 此字段只是JSON对象所有属性的一个属性。我阅读了文档,看到了JSON\u EXTRACT函数。我还是一个数据库新手,所以我想在这件事上得到一些帮助 {"user_id":"1","status_id":"1","text":"Hello, world"} 假设我想获取数据库表中所有具有“world”的“text”值。我可以使用JSON\u extract进行提取。但我想要的是模式,而不是绝对值 我该怎么做呢?您可

我需要用MariaDB从JSON字符串中提取一个字段,并在该字段中搜索特定模式

此字段只是JSON对象所有属性的一个属性。我阅读了文档,看到了
JSON\u EXTRACT
函数。我还是一个数据库新手,所以我想在这件事上得到一些帮助

{"user_id":"1","status_id":"1","text":"Hello, world"}
假设我想获取数据库表中所有具有“world”的“text”值。我可以使用
JSON\u extract
进行提取。但我想要的是模式,而不是绝对值


我该怎么做呢?

您可以使用
json\u extract()
提取值,然后使用
进行模式匹配,如

select t.*
from mytable t
where json_extract(my_json_col, '$.text') like '%world%'

您可以使用
json\u extract()
提取该值,然后使用
进行模式匹配,如

select t.*
from mytable t
where json_extract(my_json_col, '$.text') like '%world%'
当你说“我想要模式”时,你的意思是你想要能够通过模式进行过滤?例如,
Hello*
text
中,当你说“我想要模式”时,你会得到
Hello,world
,你的意思是你想要能够按模式过滤?例如,
Hello*
text
中,您可以得到
Hello,world