The AND & OR operators are used to filter records based on more than one condition. These operators are very simple to use.
The AND operator displays a record if both conditions are TRUE while the OR operator displays a record if either of the conditions are true.
Syntax
SELECT column_name(s)
FROM table_name
where columnName1='some value' AND
columnName2='some value'
|
or
SELECT column_name(s)
FROM table_name
where columnName1='some value' OR
columnName2='some value'
|
or you can also combine AND and OR to form complex expressions.
SELECT column_name(s)
FROM table_name
where columnName1='some value' AND
(columnName2='some value' OR columnName3='some value')
|
Examples
SELECT * FROM Customers
where firstName='John' AND lastName='Smith'
SELECT * FROM Customers
where firstName='John' OR firstName='Jane'
SELECT * FROM Customers
where firstName='John' AND (firstName='Jane' OR firstName='Jill')
|
Did you find the page informational and useful? Share it using one of your favorite social sites.
Recommended Books & Training Resources