AND Operator in SQL

And operator in SQL helps you filter data by more than one conditions.

Syntax of And Operator –

SELECT column1, column2
FROM table_name
WHERE condition1 AND condition2 AND condition3

Employee Table –

Let’s say you want to find out all the employee from dept 30 who is earning more than 1000.

SELECT *
FROM emp
WHERE DEPTNO = 30 AND SAL > 1000;

Here, the WHERE clause is made of two conditions and the keyword AND is used to join both the conditions. When you add an AND condition, SQL will only return rows where both the conditions is true. If one of the condition met like an employee earning more than 1000 but if the employee is not from the dept 30 then SQL will not return that entry.

If you want, you can add more than two AND conditions like this

SELECT *
FROM emp
WHERE DEPTNO = 30 AND SAL > 1000 AND JOB = 'MANAGER';

Here, we are saying give me all the records from the table where the employee makes more than 1000 and is from the dept 30 and he or she is a manager.

Rating: 1 out of 5.