Returning all data from a table
Select some columns
Filtering rows
Logic
13. Join even more conditions
Text patterns
To be or NULL to be
A bit of mathematics
Let's practice

Instruction

We can join even more conditions using parentheses, according to our needs. If we want to find only those users who are older than 70 or younger than 13 AND who are at least 180 cm tall, we can use the following expression:

SELECT
  Id,
  Name
FROM User
WHERE (Age > 70 OR Age < 13)
  AND Height >= 180;

Exercise

Select the Vin of all cars produced before 1999 or after 2005 and whose price is less than 4,000 or greater than 10,000.

Stuck? Here's a hint!

Type:

SELECT
  Vin
FROM Car
WHERE (ProductionYear < 1999 OR ProductionYear > 2005)
  AND (Price < 4000 OR Price > 10000);