AND Operator - SQL


Overview


The AND Operator in SQL is used to combine multiple conditions in a WHERE clause. It returns true only if all the specified conditions are true.

Syntax:

SELECT column
FROM table_name
WHERE condition1 AND condition2

condition1 AND condition2 checks if both condition1 and condition2 are true.

Sample Data:

first_name salary
Frank 123000
Jane 135000
Ashley 140000
Glenn 115000
Kelly 125000
Richard 120000
George 105000
Kyle 200000
James 107000
Gustavo 100000

Example


In this example, we are returning the first_name and the salary column. We then use the AND operator to filter for multiple conditions. The first condition being a salary over 110000 and the second condition being that the first_name starts with the letter G.

Example:

SELECT first_name, salary
FROM company.employees
WHERE salary > 110000 AND first_name LIKE 'G%'