I am trying to display everything that contains zbs tag2 from a JSON format that is in my MariaDB see screen.
So my query to add the values is owner varhcarm picture TEXT and tags JSON:
INSERT INTO json_pics(owner, picture, tags) VALUES ("test", "test.png",'["tag3", "tag4"]');
I'm trying to display all entries that have e.g. "tag4" in field tags with a SELECT statement as mentioned above. So that I can filter for one of the things in the brackets. This should work with JSON_CONTAINS or something like that? Image from the example DB: enter image description here
Now id 2 and 3 should be displayed because they both have tag 4 :)
Thanks in advance and many greetings, Flo
CodePudding user response:
I'm trying to display all entries that have e.g. "tag4" in field tags with a SELECT statement
SELECT *
FROM json_pics
WHERE JSON_CONTAINS(tags, '"tag4"');