Objectives
After completing this lesson, you should be able to do the following:• Limit the rows retrieved by a query
• Sort the rows retrieved by a query
Limiting Rows Using a Selection
• The WHERE clause follows the FROM clause.
Limiting the Rows Selected
• Restrict the rows returned by using the WHERE clause.• The WHERE clause follows the FROM clause.
Using the WHERE Clause
Comparison Conditions
Using Comparison Conditions
Other Comparison Conditions
Using the BETWEEN Condition
Using the IN Condition
Using the LIKE Condition
Using Comparison Conditions
Other Comparison Conditions
Using the BETWEEN Condition
Using the IN Condition
Using the LIKE Condition
• Use the LIKE condition to perform wild card searches of valid search string values.
• Search conditions can contain either literal characters or numbers:
• Search conditions can contain either literal characters or numbers:
– % denotes zero or many characters.
– _ denotes one character.
• You can combine pattern-matching characters.
• You can use the ESCAPE identifier to search for the actual % and _ symbols.
Using the NULL Conditions
Logical Conditions
Using the AND Operator
Rules of Precedence
• You can combine pattern-matching characters.
• You can use the ESCAPE identifier to search for the actual % and _ symbols.
Using the NULL Conditions
Test for nulls with the IS NULL operator.
Logical Conditions
Using the AND Operator
AND requires both conditions to be true.
Using the OR OperatorRules of Precedence
Override rules of precedence by using parentheses.
ORDER BY Clause
Sorting in Descending Order
Sorting by Column Alias
Sorting by Multiple Columns
ORDER BY Clause
• Sort rows with the ORDER BY clause
– ASC: ascending order (the default order)
– DESC: descending order
• The ORDER BY clause comes last in the SELECT statement.
– ASC: ascending order (the default order)
– DESC: descending order
• The ORDER BY clause comes last in the SELECT statement.
Sorting in Descending Order
Sorting by Column Alias
Sorting by Multiple Columns
2 comments:
nice tutorials
basics are explained in detail
examples are basic and explained beautifully.
try to include little complex examples
Post a Comment