WHERE clause can be combined with
OR operators are used to filter records based on more than one
ANDoperator displays a record if all the conditions separated by
ORoperator displays a record if any of the conditions separated by
NOT operator displays a record if the condition(s) is NOT TRUE.
The AND operator is a logical operator that combines two conditions and returns TRUE only if both condition evaluate to TRUE . The AND operator is often used in the WHERE clause of the SELECT, UPDATE, DELETE statement to form conditions to filter the result set.
The following SQL statement will return only those employees from the employees table whose salary is greater than 7000 and the dept_id is equal to 5.
SELECT * FROM employees WHERE salary > 7000 AND dept_id = 5;
OR operator is also a logical operator that combines two conditions, but it returns
TRUE when either of the conditions is
The following SQL statement will return all the employees from the employees table whose salary is either greater than 7000 or the dept_id is equal to 5.
SELECT * FROM employees WHERE salary > 7000 OR dept_id = 5;
You can also combine
OR to create complex conditional expressions.
The following SQL statement will return all the employees whose salary is greater than 5000 and the dept_id is either equal to 1 or 5.
SELECT * FROM employees WHERE salary > 5000 AND (dept_id = 1 OR dept_id = 5);