Selection

The selection operation allows you to retrieve a subset of the rows in a table. To specify the rows you want, put conditions in a WHERE clause. The SELECT statement's WHERE clause specifies the criteria that a row must meet in order to be included in the selection. For example, if you want information about publishers located in California only, here's what you'd type:

SQL
select pub_id, pub_name, address, city, state
from publishers
where state = 'CA'
					

Here are the results you would get:

Results
pub_id pub_name              address            city            state
====== ===================== ================== =============== =====
1389   Algodata Infosystems  3 3rd Dr.          Berkeley        CA
[1 row]

You can combine projection and selection in many ways to zero in on just the columns ...

Get Practical SQL Handbook, The: Using SQL Variants, Fourth 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.