Unless otherwise requested, the database server returns the rows of a table in an order that has no meaning. Often it is useful to look at the rows in a table in a more meaningful sequence. For example, you might like to see products in alphabetical order.
You order the rows in a result set by adding an ORDER BY clause to the end of the SELECT statement. This SELECT statement has the following syntax:
SELECT column-name-1, column-name-2,... FROM table-name ORDER BY order-by-column-name
You must replace column-name-1, column-name-2, and table-name with the names of the columns and table you are querying, and order-by-column-name with a column in the table. As before, you can use the asterisk as a short form for all the columns in the table.
In Interactive SQL, execute the following query:
SELECT ID, Name, Description FROM Products ORDER BY Name;
|400||Baseball Cap||Cotton Cap|
|401||Baseball Cap||Wool cap|
Discuss this page in DocCommentXchange.
|Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0|