I'm trying to figure out how to search a table's JSON array column. I found this Stackoverflow question but I'm unclear on how JSON_SEARCH works.
In the answers, people seem to be giving JSON_SEARCH direct data to search through:
SELECT JSON_SEARCH('["1","2","3","4","5"]', 'one', "2")
But since I'm making a search I don't actually have the array ["1","2","3","4","5"]
I'm creating a search query like so:
SELECT * FROM `server_list`
WHERE
`server_version` LIKE '%%'
AND
`server_name` LIKE '%%'
AND
`server_slots` > 1500
AND
`server_slots` < 4000
How can I also search for specific tags within that same query? Something along:
AND
JSON_SEARCH(`server_tags`, ['1', '2', '3'])
Where server_tags
is the column I want to search and ['1', '2', '3']
are multiple tags I want to search for.
Edit: I just realised JSON columns are just strings, which allows me to do this:
SELECT * FROM `lista_server`
`server_tags` LIKE '%value%'
OR `server_tags` LIKE '%value2%'
Is there anything wrong with this method?