如何检查 JSON 中的值?
How to check value in JSON?
我需要检查值是否在此 JSON 字段中
SELECT * FROM my_table WHERE JSON_EXTRACT(my_column, '$[*]') = 1
或
SELECT * FROM my_table WHERE 1 IN (JSON_EXTRACT(my_column, '$[*]'))
我的领域:[1,2,3,4]
解决方案:
SELECT * FROM my_table WHERE JSON_SEARCH(my_column, "one", "1") IS NOT NULL
SELECT * FROM my_table WHERE JSON_SEARCH(my_column, "one", "1") IS NOT NULL
我需要检查值是否在此 JSON 字段中
SELECT * FROM my_table WHERE JSON_EXTRACT(my_column, '$[*]') = 1
或
SELECT * FROM my_table WHERE 1 IN (JSON_EXTRACT(my_column, '$[*]'))
我的领域:[1,2,3,4]
解决方案:
SELECT * FROM my_table WHERE JSON_SEARCH(my_column, "one", "1") IS NOT NULL
SELECT * FROM my_table WHERE JSON_SEARCH(my_column, "one", "1") IS NOT NULL