To sort your results returned from a SELECT command,we use the ORDER BY clause.
SYNTAX
SELECT * FROM table_name [WHERE condition]
ORDER BY column-name(s)
EXAMPLES
SELECT * FROM TeethEyes
ORDER BY child_age
You can also sort text in alphabetical order.
SELECT * FROM TeethEyes
ORDER BY child_Eyes
How about if you want to sort in a descending order, such as the older child first. You use the DESC parameter.
SELECT * FROM TeethEyes
ORDER BY child_age DESC
One last thing. You can sort by multiple columns, and have it sort first by one and then the other, for example:
SELECT * FROM TeethEyes WHERE child_teeth>3
ORDER BY child_eyes, child_age DESC
First it sorted by the eye color in ascending order, then it sort by age in descending order.
We'll be in touch.
No comments:
Post a Comment