5

Advanced Statements

In the previous chapter, we started taking our first steps with PostgreSQL. In this chapter, we will analyze the SQL language more deeply and write more complex queries. We will talk about SELECT/INSERT/UPDATE again, but this time, we will use the more advanced options surrounding them. We will then cover joins, common table expressions (CTEs), and merge in depth.

The topics we will talk about will be the following:

  • Exploring the SELECT statement
  • Using UPSERT and MERGE
  • Exploring CTEs

Technical requirements

Before starting, remember to start the Docker container named chapter_05, as shown below:

$ bash run-pg-docker.sh chapter_05
postgres@learn_postgresql:~$ psql -U forum forumdb

Exploring the SELECT statement

As we saw ...

Get Learn PostgreSQL - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.