Basic query for PostgreSQL to remember

ehdtlaos

Edrick Ee

Posted on August 14, 2021

Basic query for PostgreSQL to remember

Basic query:

SELECT column, column, column
FROM table
WHERE table.column = ${whatever}
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
ehdtlaos
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.

Related