Professional Documents
Culture Documents
Objectives
Limit the rows retrieved by a query Sort the rows retrieved by a query
Comparison Conditions
Operator
= > >= < <= <>
Meaning
Equal to Greater than Greater than or equal to Less than Less than or equal to Not equal to
BETWEEN ...AND...
IN(set) LIKE IS NULL
Lower limit
Upper limit
Logical Conditions
Operator Meaning
AND
OR
NOT
Rules of Precedence
Order Evaluated 1 2 3 4 5 6 7 8 Operator Arithmetic operators Concatenation operator Comparison conditions IS [NOT] NULL, LIKE, [NOT] IN [NOT] BETWEEN NOT logical condition AND logical condition OR logical condition
Rules of Precedence
SELECT FROM WHERE OR AND last_name, job_id, salary employees job_id = 'SA_REP' job_id = 'AD_PRES' salary > 15000;
Rules of Precedence
Use parentheses to force priority.
SELECT FROM WHERE OR AND last_name, job_id, salary employees (job_id = 'SA_REP' job_id = 'AD_PRES') salary > 15000;
ORDER BY Clause
Sort rows with the ORDER BY clause ASC: ascending order, default DESC: descending order The ORDER BY clause comes last in the SELECT statement.
SELECT last_name, job_id, department_id, hire_date FROM employees ORDER BY hire_date ;
Summary
In this lesson, you should have learned how to: