Wednesday, December 18, 2024

SQL AND Keyword

 The AND keyword in SQL is used to combine multiple conditions in a WHERE clause. It allows you to filter records based on more than one condition. The result will only include rows that satisfy all the conditions combined with AND.

Syntax:

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

Example:

Suppose you have a table called Employees with columns FirstName, LastName, Age, and Salary, and you want to retrieve employees who are older than 30 and have a salary greater than 50,000:

SELECT FirstName, LastName, Age, Salary
FROM Employees
WHERE Age > 30 AND Salary > 50000;

In this case, only employees who meet both conditions (age > 30 and salary > 50,000) will be returned.

No comments:

Post a Comment