~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/where.rst

  • Committer: Lee Bieber
  • Date: 2011-03-29 22:31:41 UTC
  • mfrom: (2257.1.3 build)
  • Revision ID: kalebral@gmail.com-20110329223141-yxc22h3l2he58sk0
Merge Andrew - 743842: Build failure using GCC 4.6
Merge Stewart - 738022: CachedDirectory silently fails to add entries if stat() fails
Merge Olaf - Common fwd: add copyright, add more declaration

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Where
 
2
=====
 
3
 
 
4
The WHERE clause is used to extract only those records that fulfill a specified criterion.
 
5
 
 
6
Simple SQL WHERE Syntax:
 
7
 
 
8
.. code-block:: mysql
 
9
 
 
10
        SELECT column_name(s)
 
11
        FROM table_name
 
12
        WHERE column_name operator value
 
13
        
 
14
**Simple WHERE Clause Example**
 
15
 
 
16
The "Persons" table:
 
17
 
 
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
+---------+------------+----------+----------+--------+
 
27
 
 
28
If you want to select only the persons living in the city "Chicago" from the table above, use the following SELECT statement:
 
29
 
 
30
.. code-block:: mysql
 
31
 
 
32
        SELECT * FROM Persons
 
33
        WHERE City='Chicago'
 
34
 
 
35
The result-set will look like this:
 
36
 
 
37
+---------+------------+----------+----------+--------+
 
38
| Id      |LastName    |FirstName |Address   |City    |
 
39
+=========+============+==========+==========+========+
 
40
|1        | Larson     | Sue      |3 Cherry  | Chicago|
 
41
+---------+------------+----------+----------+--------+
 
42
|2        | Roberts    | Teri     |21 Brown  | Chicago|
 
43
+---------+------------+----------+----------+--------+