I have a MySQL 5.7 table which includes a column of type VARCHAR named 'area' which contains JSON data. For example ["BS20","BS21"]
I need to search on that table to find the first row containing a particular string. The string is contained in a variable like
$area = BS20;
and I have tried this for my query
SELECT * FROM aedv2_admin WHERE JSON_CONTAINS(area,'$area')=1
and I get an error
Invalid JSON text in argument 2 to function json_contains: "Invalid value." at position 0.12
For testing I have tried hard coding argument 2 as BS20 and 'BS20' but neither helps. What am I doing wrong?
'$area'after the substitution must give'"BS20"'. dbfiddle.uk/…