In SQL, the AND
operator is a logical operator used to combine multiple conditions in a WHERE
clause. It is used to filter rows based on multiple conditions, and all conditions must evaluate to true for the row to be included in the result set.
Here's the syntax for using the AND
operator:
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND ...;
For example, if you have a table called employees
and you want to retrieve employees who are both from the 'Marketing' department and have a salary greater than $50000, you would use the AND
operator like this:
SELECT *
FROM employees
WHERE department = 'Marketing' AND salary > 50000;
This query will return all rows from the employees
table where the department is 'Marketing' and the salary is greater than $50000.
The AND
operator can be used with any number of conditions, allowing you to create complex filtering criteria to retrieve the desired subset of data.