2.6. SELECT

An SQL select statement is used to select certain rows from a table or tables. A select query will return as many rows as match the criteria.

2.6.1. Syntax

select field1 [, field2, field3] from table1 [, table2]
        where condition
        order by field [desc]

2.6.2. Examples

select id, name from customer;
select id, name from customer order by name;
select id, name from customer order by name desc;

We can use a select statement to obtain data from multiple tables. This is referred to as a ``join''.

select * from customer, sales where customer.id = sales.customer_id