8.11. Combining Queries and Ranges of Values

In some cases the queries you have already seen will not be enough to satisfy your demands. The ANSI SQL standard defines several ways to combine queries, which are covered in this section.

Let's define two tables: The first one stores a list of registered users. The second table contains the postings of the various users:

phpbook=# CREATE TABLE reg_user (name text, regdate date);
CREATE
phpbook=# CREATE TABLE user_post (name text, postdate date, message text);
CREATE

For this scenario three users are added to the table:

phpbook=# INSERT INTO reg_user VALUES ('Paul', '2001/03/12');
INSERT 26059 1
phpbook=# INSERT INTO reg_user VALUES ('Shelley', '2001/02/22');
INSERT 26060 1
phpbook=# INSERT INTO ...

Get PHP and PostgreSQL: Advanced Web Programming 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.