Combining conditions
Often it's not enough to check for only one condition. What if we want to check if multiple conditions hold at the same time? Or at least one of them?
Conditions in SQL can be combined by using AND
and OR
statements within WHERE
block. AND
checks if all the conditions hold while OR
checks if at least one of the conditions holds. For example, we can combine conditions from the two previous chapters: filter for hybrid cars with mileage less than 5000 miles.
123SELECT * FROM audi_cars WHERE fueltype = 'Hybrid' AND mileage < 5000
Also, we can extract only either cars with Automatic transmission either with an engine size less than 3 by using OR
statement.
123SELECT * FROM audi_cars WHERE transmission = 'Automatic' OR enginesize < 3
Swipe to start coding
From audi_cars
table extract only Diesel cars (fueltype
column) with mileage
less than 2000.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 2.63Awesome!
Completion rate improved to 2.63
Combining conditions
Often it's not enough to check for only one condition. What if we want to check if multiple conditions hold at the same time? Or at least one of them?
Conditions in SQL can be combined by using AND
and OR
statements within WHERE
block. AND
checks if all the conditions hold while OR
checks if at least one of the conditions holds. For example, we can combine conditions from the two previous chapters: filter for hybrid cars with mileage less than 5000 miles.
123SELECT * FROM audi_cars WHERE fueltype = 'Hybrid' AND mileage < 5000
Also, we can extract only either cars with Automatic transmission either with an engine size less than 3 by using OR
statement.
123SELECT * FROM audi_cars WHERE transmission = 'Automatic' OR enginesize < 3
Swipe to start coding
From audi_cars
table extract only Diesel cars (fueltype
column) with mileage
less than 2000.
Oplossing
Bedankt voor je feedback!
single
Awesome!
Completion rate improved to 2.63
Combining conditions
Veeg om het menu te tonen
Often it's not enough to check for only one condition. What if we want to check if multiple conditions hold at the same time? Or at least one of them?
Conditions in SQL can be combined by using AND
and OR
statements within WHERE
block. AND
checks if all the conditions hold while OR
checks if at least one of the conditions holds. For example, we can combine conditions from the two previous chapters: filter for hybrid cars with mileage less than 5000 miles.
123SELECT * FROM audi_cars WHERE fueltype = 'Hybrid' AND mileage < 5000
Also, we can extract only either cars with Automatic transmission either with an engine size less than 3 by using OR
statement.
123SELECT * FROM audi_cars WHERE transmission = 'Automatic' OR enginesize < 3
Swipe to start coding
From audi_cars
table extract only Diesel cars (fueltype
column) with mileage
less than 2000.
Oplossing
Bedankt voor je feedback!