7.3. Building Simple SQL Statements

Now that you have seen how tables can be added to a database, it is time to perform some simple SQL statements.

One of the most important commands when working with SQL is the INSERT command. INSERT is one way to add data to a table. Since the first days of SQL, the INSERT command has been part of the ANSI SQL specification, and it is a core component of every relational and object relational database built in SQL. The syntax overview of the INSERT command is not too complicated:

phpbook=# \h INSERT
Command:     INSERT
Description: create new rows in a table
Syntax:
INSERT INTO table [ ( column [, ...] ) ]
    { DEFAULT VALUES | VALUES ( expression [, ...] ) | SELECT query }

The first thing you have to define is ...

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.