I can use this mysql query to search for all rows where attribute ‘color’ is Red
SELECT * FROM table WHERE JSON_EXTRACT(`attribute`,'$.color') = 'Red'
I can use this mysql query to search for all rows where attribute ‘color’ is not Red
SELECT * FROM table WHERE JSON_EXTRACT(`attribute`,'$.color') != 'Red'
But how do I search for all rows where attribute ‘color’ is found regardless of color? And how do I search for all rows where attribute ‘color’ is not found?
Advertisement
Answer
Use next queries:
SELECT * FROM tbl WHERE JSON_EXTRACT(`attribute`,'$.color') IS NULL ; SELECT * FROM tbl WHERE JSON_EXTRACT(`attribute`,'$.color') IS NOT NULL ;