SQL AND Operator

AND Operator is used to applying multiple conditions in the query. AND Operator is a part of the logical operator and It is applicable in INSERT/UPDATE/DELETE operations.

In SELECT Statement

Syntax:-

SELECT column(s) 
FROM table_name 
WHERE condition1 AND condition2 AND condition3....

In UPDATE Statement

Syntax:-

UPDATE table_name
SET column1=value1, column2=value2.....
WHERE condition1 AND condition2 AND condition3....

In INSERT Statement

Syntax:-

INSERT INTO table_name (column1,column2.....) 
VALUES (value1,value2....)
WHERE condition1 AND condition2 AND condition3....

Example:- Suppose we have employees table which has 7 records

+----+------------+-----------+----------------+-----------+
| id | first_name | last_name | email          | country   |
+----+------------+-----------+----------------+-----------+
|  1 | John       | Tailor    | john@abc.com   | USA       |
|  2 | Rom        | Tailor    | rom@abc.com    | USA       |
|  3 | Andrew     | Symonds   | andrew@abc.com | Australia |
|  4 | Miacle     | clerk     | miacle@abc.com | Australia |
|  5 | Sachin     | Tendulkar | sachin@abc.com | India     |
|  6 | Virat      | Kohli     | virat@abc.com  | India     |
|  7 | rohit      | NULL      | rohit@abc.com  | India     |

Now, we have to get the employees who have country INDIA and firstName Virat.

SELECT * FROM employees
where country='India' AND first_name='Virat';

Output:-

 +----+------------+-----------+---------------+---------+
| id | first_name | last_name | email         | country |
+----+------------+-----------+---------------+---------+
|  6 | Virat      | Kohli     | virat@abc.com | India   |
+----+------------+-----------+---------------+---------+
1 row in set (0.00 sec)