Reputation: 25
whats the MySQL sql
comand equivalent of this :
select id where not json_search(example,'one','0')
it selects only elements where there is no '0'
in the json array of the column named example.
Upvotes: 1
Views: 532
Reputation: 562270
The json_search()
function returns NULL when it finds no match. It does not return false
. You can't use NOT
to negate it, because NULL is not false. The negation of NULL
is still NULL
.
You can query it this way:
select id from ...mytable...
where json_search(example, 'one', '0') is [not] null;
Use is null
if you want cases where no match is found.
Use is not null
if you want cases where a match is found.
Upvotes: 2