Basic query for PostgreSQL to remember
Edrick Ee
Posted on August 14, 2021
Basic query:
SELECT column, column, column
FROM table
WHERE table.column = ${whatever}
Query with nested array with join table:
SELECT column1, column2, json_agg(json_build_object('key', value) AS name_your_key
FROM table1
LEFT JOIN table2
ON table1.id = table2.table1.id
WHERE table1.id = ${whatever}
GROUP BY column1, column2
💖 💪 🙅 🚩
Edrick Ee
Posted on August 14, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.