JSON
Learn SQL json with practical examples and guided drills on dbSyntax.
Start with JSON in SQLJSON in SQL
Read, write, query, and aggregate JSON data inside SQL. Used everywhere data lands as semi-structured payloads: event logs, API responses, u...
Extract a field from JSON
Short answer: the syntax differs more across engines than any other JSON operation. Postgres and DuckDB use -> (returns JSON) and ->> (retur...
Postgres jsonb operators
Postgres ships an entire algebra of operators for the jsonb type — extraction, containment, key existence, path traversal, and merge. Knowin...
Unnest a JSON array into rows
Short answer: explode a JSON-array column into one row per element. Postgres uses jsonb_array_elements (or json_array_elements); BigQuery us...
Build JSON from rows
Short answer: JSON_AGG(col) aggregates rows into a JSON array; JSON_OBJECT('key', val, ...) builds a single object from columns; JSON_OBJECT...
Update a field inside JSON
Short answer: modify a nested value without rewriting the whole document. Postgres uses jsonb_set(col, path, value). MySQL uses JSON_SET. Sn...