The logical operators are AND, OR, and NOT. AND and OR are used to connect search conditions in WHERE clauses. NOT reverses the result of a search condition.
AND joins two conditions and returns TRUE only when both conditions are true. For example, this query returns only the one row in which the customer ID starts with the letter F and the contact name is Lino Rodriguez.
SELECT CustomerID, CompanyName, ContactName
FROM Northwind.dbo.Customers
WHERE CustomerID LIKE N'F%'
AND ContactName = N'Lino Rodriguez'
OR also connects two conditions, but it returns TRUE when either of the conditions is true. The following query returns two rows, one with a customer ID of CACTU and the other with a contact name of Lino Rodriguez.
SELECT CustomerID, CompanyName, ContactName
FROM Customers
WHERE CustomerID = N'CACTU'
OR ContactName = N'Lino Rodriguez'
WHERE | Operators |