It is often required to filter records in a table using the where clause. If there is a need for filter records using more than one condition and all conditions must be true then we need to use SQL AND operator.
SQL AND is a logical operator. It returns true if all conditions will return true.
SQL AND Syntax
Select column1, column2,... columnN from table_name WHERE condition1 and condition2;
Sample Table
Employee
Example
- Select all records from Employee table where salary is greater than 40000 and age is greater than 30
SELECT * FROM Employee WHERE SALARY > 40000 and AGE > 30;
- Select all records from Employee table where salary is greater than 40000 and age is greater than 30 and designation is SDE II
SELECT * FROM Employee WHERE SALARY > 40000 and AGE > 30 AND DESIGNATION = 'SDE II';
This is how the AND operator works.
Hope you liked the article. If you have any doubts or concerns, please feel free to write us in comments or mail us at admin@codekru.com