CHAPTER 2
- WHERE Conditions
- Comparison operators
- BETWEEN operator
- IN operator
- LIKE operator
- IS NULL operator
- Logical operators
- AND operator
- OR operator
- NOT operator
- ORDER BY operator
RESTRICTING ROWS WITH WHERE
- WHERE statement can be used to return only specific rows.
- WHERE statement must be written after the SELECT statement.
- The condition that defined in the WHERE statement, can include; values in column , literal values, arithemtic expressions or functions.
- SELECT *|{[DISTINCT] column|expression [alias],…} FROM table [WHERE condition(s)
- Let’s list the employees which department_ID are 80.
SELECT employee_id, first_name,last_name, job_id, department_id FROM hr.employees WHERE department_id=80;
COMPARISON OPERATORS
- Let’s list the employees which salary is 3000 or less.
SELECT first_name,last_name, salary FROM hr.employees WHERE salary <= 3000 ;
IN OPERATOR
- Let’s list the employees which Manager_id is 100, 101 or 201.
SELECT employee_id, first_name,last_name, salary, manager_id FROM hr.employees WHERE manager_id IN (100, 101, 201) ;
LIKE OPERATOR
- Let’s list the employees that has ‘e’ character in his/her name.
SELECT first_name,last_name FROM hr.employees WHERE first_name LIKE '%e%' ;
- Let’s list the employees that surname’s second character is ‘o’.
SELECT first_name,last_name FROM hr.employees WHERE last_name LIKE '_o%' ;
You can contunie to read from this link ;
Enjoyed examining this, very good stuff, appreciate it.
good stuff, “equal to” comparison operator should be single “=”.