2015. 6. 7. 18:59
The AND & OR operators are used to filter records based on more than one condition.
The SQL AND & OR Operators
The AND operator displays a record if both the first condition AND the second condition are true.
The OR operator displays a record if either the first condition OR the second condition is true.
AND Operator Example
The following SQL statement selects all customers from the country "Germany" AND the city "Berlin", in the "Customers" table:
OR Operator Example
The following SQL statement selects all customers from the city "Berlin" OR "München", in the "Customers" table:
Combining AND & OR
You can also combine AND and OR (use parenthesis to form complex expressions).
The following SQL statement selects all customers from the country "Germany" AND the city must be equal to "Berlin" OR "München", in the "Customers" table:
Example
SELECT * FROM Customers
WHERE Country='Germany'
AND (City='Berlin' OR City='München');
WHERE Country='Germany'
AND (City='Berlin' OR City='München');
Try it yourself »
'SQL' 카테고리의 다른 글
INSERT INTO (0) | 2015.06.07 |
---|---|
ORDER BY (0) | 2015.06.07 |
WHERE Clause (0) | 2015.06.07 |
SELECT DISTINCT Statement (0) | 2015.06.07 |
SQL SELECT (0) | 2015.06.07 |