AND Operator in SQL

The AND operator in SQL is used to combine multiple conditions in a WHERE or HAVING clause. All the conditions combined with AND must be true for the overall condition to be true.

SQL Syntax

SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND ...;

Examples: Example with WHERE Clause Suppose we have a table employees with the following columns: employee_id, first_name, last_name, department_id, and salary. Table: employees

employee_idfirst_namelast_namedepartment_idsalary
1JohnDoe150000
2JaneSmith260000
3MichaelO'Connor155000
4SarahO'Brien345000
5LauraWilson270000

We want to find employees who are in department 1 and have a salary greater than 50000.

SQL

SELECT first_name, last_name, department_id, salary
FROM employees
WHERE department_id = 1 AND salary > 50000; 

Result

first_namelast_namedepartment_idsalary
MichaelO'Connor155000