There are many clauses, and combinations thereof, that can be used with a SELECT statement to yield particular table query results. They range from very basic, commonly-used options to very specialized and complex. The following basic, optional clauses will be covered in this section:
Clauses Definition
DISTINCT Eliminates duplicate row data
FROM Specifies what table(s) to retrieve data from
WHERE Decides what data to show
ORDER BY Sorts data by specified order criteria
LIMIT Reduces the amount of records received
Example of SELECT statement with clauses:
SELECT DISTINCT values_to_display FROM table_name WHERE expression ORDER BY how_to_sort LIMIT row_count;
The above syntax shows the correct order and usage of each of the above optional clauses. This statement is specifically selecting distinct data rows from a named table, where some expression defines what data to show and it is ordered by a sorting criteria, and the number of rows to be retrieved is limited by some number.
Comments
Post a Comment