Table: `users`
| id | name | profile |
|---|---|---|
| 1 | Alice | {"address":{"city":"Paris","zip":"75001"}} |
| 2 | Bob | {"address":{"city":"Lyon","zip":"69001"}} |
| 3 | Carol | {"address":{"city":"Paris","zip":"75002"}} |
Write a query that returns the id and name of every user whoseprofile.address.city is 'Paris'.
Expected output (columns: id, name), ordered by id:
1|Alice
3|CarolHint —
json_extractaccepts multi-level paths directly:
json_extract(profile, '$.address.city')reaches two levels deep in onecall. You can filter on the extracted value in a normal
WHEREclause.
Sample tests