Monday, 29 August 2016

Join Even More Conditions



We can join even more conditions using brackets, according to our needs. If we want to find only those users who are above 70 years old or below 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);










 Syntax
 SELECT * FROM table_name WHERE (column_name <value OR column_name >value )  AND (column_name <value OR column_name >value );


Exercise

Select vin of all cars which were produced before 1999 or after 2005 and whose price is lower than 4 000 or greater than 10 000.

Execute below code
SELECT vin FROM car WHERE (production_year <1999 OR production_year >2005)  AND (price<4000 OR price>10000);


VIN
WPOZZZ79ZTS372128
KLATF08Y1VB363636
1M8GDM9AXKP042788

No comments:

Post a Comment