我希望能够对json_contains
这是JSON示例:
[
{
"title": "foo Bar",
"author": "melaine"
},
{
"title": "incredible",
"author": "steve"
}
]
我尝试的是:
SELECT json_contains('[{"title":"foo Bar", "authour": "melaine"}, {"title":"foo barius", "authour": "steve"}]', '{"title":"foo bar"}')
预期结果:1
实际结果:0
因为我在寻找" foo bar",而json中的值是" foo bar",我没有得到比赛。有没有办法使这种情况不敏感,所以我确实会匹配?
您可以使用 LOWER()
函数将json(haystack(和搜索块(针(转换为小写,以供案例不敏感的搜索:
SELECT json_contains(LOWER('[{"title":"foo Bar", "authour": "melaine"}, {"title":"foo barius", "authour": "steve"}]'),
LOWER('{"title":"foo bar"}'))
db小提琴演示