4
The WHERE clause is used to extract only those records that fulfill a specified criterion.
6
Simple SQL WHERE Syntax:
12
WHERE column_name operator value
14
**Simple WHERE Clause Example**
18
+---------+------------+----------+----------+--------+
19
|Id |LastName |FirstName |Address | City |
20
+=========+============+==========+==========+========+
21
| 1 | Larson | Sue |3 Cherry | Chicago|
22
+---------+------------+----------+----------+--------+
23
| 2 | Roberts | Teri |21 Brown | Chicago|
24
+---------+------------+----------+----------+--------+
25
| 3 | Peterson | Kari |30 Mell | Reno |
26
+---------+------------+----------+----------+--------+
28
If you want to select only the persons living in the city "Chicago" from the table above, use the following SELECT statement:
35
The result-set will look like this:
37
+---------+------------+----------+----------+--------+
38
| Id |LastName |FirstName |Address |City |
39
+=========+============+==========+==========+========+
40
|1 | Larson | Sue |3 Cherry | Chicago|
41
+---------+------------+----------+----------+--------+
42
|2 | Roberts | Teri |21 Brown | Chicago|
43
+---------+------------+----------+----------+--------+