Programming instructions
Using a web page to list trips 63
Consider a table named Clients to hold information about people with the following
rows:
To select the columns named LastName and FirstName, use the following SELECT
statement:
SELECT LastName, FirstName FROM Clients
The results of this SQL statement contains the following data:
Using the SQL WHERE clause to limit the rows returned
To conditionally select data from a table, you can add a WHERE clause to the SELECT
statement resulting in the following syntax:
SELECT column_name FROM table_name WHERE column condition value
With the WHERE clause, you can use any of the following operators:
LastName FirstName Address City
Jones Tom 12 State St Boston
Adams Anita 521 Beacon St Boston
Green Peter 1 Broadway New York
LastName FirstName
Jones Tom
Adams Anita
Green Peter
Operator Description
=Equal
<> Not equal
> Greater than
<Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
AND Joins one or more conditions
OR Joins one or more conditions
LIKE Specifies a search for a pattern in a column. You can use a "%" sign to
define wildcards (missing letters in the pattern) before and after the
pattern.