SELECT..FROM..WHERE

If you want to limit the number of rows returned in a query, WHERE clause is used. The syntax for the command is

SELECT <col_name1>, ....

FROM     <table_name1>, ....

WHERE <col_name><operator><value>, ........

For a definition of the operators, follow the link

Lets look at the following table tbl_employee again.

Social_Security Last_ Name First_Name Address Zip_Code
476-02-3475 Mitchel John 1223 West Palm Beach Rd 85023
376-76-9083 Spencer Teri 2349 S. 76th Street #102 53219
733-05-3598 James Taylor 23 N. Atlantic Blvd 76215
387-41-1189 Pewinsky Lewis 675 E Indian School Rd 85023
498-32-9089 James Sue 3567 E Tatum Blvd 85032


If you want to limit the number of fields from the table use the following command

SELECT First_Name, Last_Name, Zip_Code 

FROM tbl_employee

WHERE Zip_Code=85023


The following is the results of your query of the database:

Last_Name First_Name Zip_Code
Mitchel John 85023
Pewinsky Lewis 85023

As you can see, using the WHERE clause limited the number of rows from five to two.

Back to the homepage