My json is of the format [“a”,”b”,”c”]. I want to write a sql query such that
select * from mytable where a_column in json_extract["a","b","c"]
This logic does not work, because json_extract needs a path.
Is there any work around for this in mysql 8.0
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
SELECT * FROM mytable WHERE JSON_CONTAINS('["a","b","c"]', JSON_QUOTE(a_column));
I assume that the column
a_column is a string-type column which contains a value like
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0