AND operator in SQL Server

The AND operator in SQL Server is used to combine two or more conditions in a WHERE clause. It returns true only if all the conditions are true. Here is an example of how to use the AND operator in SQL Server:

Syntax: -

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

The AND operator can be used with other operators such as LIKE, IN, and BETWEEN. For example, the following SQL statement selects all customers from Spain whose name starts with the letter ‘G’:

SELECT * FROM Customers

WHERE Country = \’Spain\’ AND CustomerName LIKE \’G%\’;

  1. Select all Spanish customers that starts with either \”G\” or \”R\”:

SELECT * FROM Customers
WHERE Country = \’Spain\’ AND (CustomerName LIKE \’G%\’ OR CustomerName LIKE \’R%\’);

  1. Select all Spanish customers that starts with \”G\” As well as “R\”:

SELECT * FROM Customers
WHERE Country = \’Spain\’ AND CustomerName LIKE \’G%\’ OR CustomerName LIKE \’R%\’;