SyntaxStudy
Sign Up
MySQL Filtering on JSON Values
MySQL Intermediate 3 min read

Filtering on JSON Values

Filtering on JSON

Use -> or JSON_EXTRACT() in WHERE clauses to filter rows based on JSON field values.

Example
-- Find products where ram = 16
SELECT name FROM products
WHERE attributes->'$.ram' = 16;

-- Find products where ssd is true
SELECT name FROM products
WHERE JSON_EXTRACT(attributes, '$.ssd') = true;
Pro Tip

Without a generated column index, JSON WHERE filters do full table scans.