Databases Reference
In-Depth Information
+-------+-----------------------------------------------------+
| 1.34 | Intermission By Alan Wise [Olympia, Paris 12/11/01] |
| 1.81 | In A Silent Way |
| 11.37 | Breaking Into Heaven |
| 12.80 | Human Nature |
| 16.67 | Shhh/Peaceful |
| 16.67 | In A Silent Way/It's About That Time |
| 2.38 | Rip This Joint |
| 2.78 | Jangling Jack |
| 2.81 | Full Nelson |
...
The results are ordered alphabetically, so that, for example, numbers beginning with
1 appear before numbers beginning with 2. The CAST( ) function forces a column to be
treated as a different type, in this example as a character string using the AS CHAR clause.
You can specify:
AS BINARY , to sort as binary, which has the same effect as ORDER BY BINARY
AS SIGNED , to sort as a signed integer
AS UNSIGNED , to sort as an unsigned integer
AS CHAR , to sort as a character string
AS DATE , to sort as a date
AS DATETIME , to sort as a date and time
AS TIME , to sort as a time
The types of columns are discussed in detail in “Column Types” in Chapter 6.
The LIMIT Clause
The LIMIT clause is a useful, nonstandard SQL tool that allows you to control which
rows are output. Its basic form allows you to limit the number of rows returned from
a SELECT statement, which is useful when you want to limit the amount of data com-
municated over a network or output to the screen. You might use it, for example, in a
web database application, where you want to find the rows that match a condition but
only want to show the user the first 10 rows in a web page. Here's an example:
mysql> SELECT track_name FROM track LIMIT 10;
+----------------------------+
| track_name |
+----------------------------+
| Do You Love Me? |
| Nobody's Baby Now |
| Loverman |
| Jangling Jack |
| Red Right Hand |
| I Let Love In |
| Thirsty Dog |
| Ain't Gonna Rain Anymore |
| Lay Me Low |
 
Search WWH ::




Custom Search