Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Combining conditions | Filtering
SQL Basics
course content

Conteúdo do Curso

SQL Basics

SQL Basics

1. Selecting
2. Filtering
3. Aggregating
4. Sorting
5. Grouping
6. Practicing

bookCombining 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.

123
SELECT * FROM audi_cars WHERE fueltype = 'Hybrid' AND mileage < 5000
copy

Also, we can extract only either cars with Automatic transmission either with an engine size less than 3 by using OR statement.

123
SELECT * FROM audi_cars WHERE transmission = 'Automatic' OR enginesize < 3
copy
Tarefa
test

Swipe to show code editor

From audi_cars table extract only Diesel cars (fueltype column) with mileage less than 2000.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 3
toggle bottom row

bookCombining 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.

123
SELECT * FROM audi_cars WHERE fueltype = 'Hybrid' AND mileage < 5000
copy

Also, we can extract only either cars with Automatic transmission either with an engine size less than 3 by using OR statement.

123
SELECT * FROM audi_cars WHERE transmission = 'Automatic' OR enginesize < 3
copy
Tarefa
test

Swipe to show code editor

From audi_cars table extract only Diesel cars (fueltype column) with mileage less than 2000.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 3
toggle bottom row

bookCombining 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.

123
SELECT * FROM audi_cars WHERE fueltype = 'Hybrid' AND mileage < 5000
copy

Also, we can extract only either cars with Automatic transmission either with an engine size less than 3 by using OR statement.

123
SELECT * FROM audi_cars WHERE transmission = 'Automatic' OR enginesize < 3
copy
Tarefa
test

Swipe to show code editor

From audi_cars table extract only Diesel cars (fueltype column) with mileage less than 2000.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

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.

123
SELECT * FROM audi_cars WHERE fueltype = 'Hybrid' AND mileage < 5000
copy

Also, we can extract only either cars with Automatic transmission either with an engine size less than 3 by using OR statement.

123
SELECT * FROM audi_cars WHERE transmission = 'Automatic' OR enginesize < 3
copy
Tarefa
test

Swipe to show code editor

From audi_cars table extract only Diesel cars (fueltype column) with mileage less than 2000.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 2. Capítulo 3
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
We're sorry to hear that something went wrong. What happened?
some-alt