~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/orderby.rst

edit

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
The ORDER BY keyword is used to sort the result-set by column; by default, it sorts the records in ascending order.
5
5
 
6
 
SQL ORDER BY Syntax:
7
 
 
8
 
.. code-block:: mysql
 
6
SQL ORDER BY Syntax: ::
9
7
 
10
8
        SELECT column_name(s)
11
9
        FROM table_name
25
23
| 3       | Peterson   | Kari     |30 Mell   | Reno   |
26
24
+---------+------------+----------+----------+--------+
27
25
 
28
 
To select all the persons from the table above, and also sort them by their last name, use the following SELECT statement:
29
 
 
30
 
.. code-block:: mysql
 
26
To select all the persons from the table above, and also sort them by their last name, use the following SELECT statement: ::
31
27
 
32
28
        SELECT * FROM Persons
33
29
        ORDER BY LastName;
44
40
| 2       | Roberts    | Teri     |21 Brown  | Chicago|
45
41
+---------+------------+----------+----------+--------+
46
42
 
47
 
ORDER BY DESC can be used to reverse the order of the result set.
48
 
 
49
 
.. code-block:: mysql
 
43
ORDER BY DESC can be used to reverse the order of the result set. ::
50
44
 
51
45
        SELECT * FROM Persons
52
46
        ORDER BY LastName DESC;
53
47
 
54
 
.. todo::
55
 
 
56
 
   add something about SELECT * without ORDER BY being non-deterministic
57
 
 
58
 
.. todo::
59
 
 
60
 
   add something about how ORDER BY is executed. index scan vs filesort
 
48
FIXME: add something about SELECT * without ORDER BY being non-deterministic
 
49
 
 
50
FIXME: add something about how ORDER BY is executed. index scan vs filesort