~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/orderby.rst

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
merge lp:~olafvdspek/drizzle/refactor5

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: ::
 
6
SQL ORDER BY Syntax:
 
7
 
 
8
.. code-block:: mysql
7
9
 
8
10
        SELECT column_name(s)
9
11
        FROM table_name
23
25
| 3       | Peterson   | Kari     |30 Mell   | Reno   |
24
26
+---------+------------+----------+----------+--------+
25
27
 
26
 
To select all the persons from the table above, and also sort them by their last name, use the following SELECT statement: ::
 
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
27
31
 
28
32
        SELECT * FROM Persons
29
33
        ORDER BY LastName;
40
44
| 2       | Roberts    | Teri     |21 Brown  | Chicago|
41
45
+---------+------------+----------+----------+--------+
42
46
 
43
 
ORDER BY DESC can be used to reverse the order of the result set. ::
 
47
Without using "ORDERBY" in the following query, the result-set will be non-deterministic, and could returned matching rows in a different order for each query. 
 
48
 
 
49
ORDER BY DESC can be used to reverse the order of the result set.
 
50
 
 
51
.. code-block:: mysql
44
52
 
45
53
        SELECT * FROM Persons
46
54
        ORDER BY LastName DESC;
47
55
 
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
 
56
 
 
57
.. todo::
 
58
 
 
59
   add something about how ORDER BY is executed. index scan vs filesort