Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Multiple filtering on one column | Filtering
SQL Basics
course content

Course Content

SQL Basics

SQL Basics

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

Multiple filtering on one column

What if we are interested only in two models: let it be A4 and A5?

Of course, we could write WHERE model = 'A4' OR model = 'A5'. But is there a point in writing two conditions for the same column? This problem is also solved in SQL by using IN statement. To check if a value from a column is one of acceptable use WHERE column IN ('value1', 'value2', ...) syntax. For example,

123
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
copy

WHERE column IN ('value1', 'value2') is equvivalent to WHERE column = 'value1' OR column = 'value2'. It also works for numeric values.

Task

From audi_cars extract cars with engine size (enginesize column) 1.5 and 2.9 using IN statement.

Task

From audi_cars extract cars with engine size (enginesize column) 1.5 and 2.9 using IN statement.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 5
toggle bottom row

Multiple filtering on one column

What if we are interested only in two models: let it be A4 and A5?

Of course, we could write WHERE model = 'A4' OR model = 'A5'. But is there a point in writing two conditions for the same column? This problem is also solved in SQL by using IN statement. To check if a value from a column is one of acceptable use WHERE column IN ('value1', 'value2', ...) syntax. For example,

123
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
copy

WHERE column IN ('value1', 'value2') is equvivalent to WHERE column = 'value1' OR column = 'value2'. It also works for numeric values.

Task

From audi_cars extract cars with engine size (enginesize column) 1.5 and 2.9 using IN statement.

Task

From audi_cars extract cars with engine size (enginesize column) 1.5 and 2.9 using IN statement.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 2. Chapter 5
toggle bottom row

Multiple filtering on one column

What if we are interested only in two models: let it be A4 and A5?

Of course, we could write WHERE model = 'A4' OR model = 'A5'. But is there a point in writing two conditions for the same column? This problem is also solved in SQL by using IN statement. To check if a value from a column is one of acceptable use WHERE column IN ('value1', 'value2', ...) syntax. For example,

123
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
copy

WHERE column IN ('value1', 'value2') is equvivalent to WHERE column = 'value1' OR column = 'value2'. It also works for numeric values.

Task

From audi_cars extract cars with engine size (enginesize column) 1.5 and 2.9 using IN statement.

Task

From audi_cars extract cars with engine size (enginesize column) 1.5 and 2.9 using IN statement.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

What if we are interested only in two models: let it be A4 and A5?

Of course, we could write WHERE model = 'A4' OR model = 'A5'. But is there a point in writing two conditions for the same column? This problem is also solved in SQL by using IN statement. To check if a value from a column is one of acceptable use WHERE column IN ('value1', 'value2', ...) syntax. For example,

123
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
copy

WHERE column IN ('value1', 'value2') is equvivalent to WHERE column = 'value1' OR column = 'value2'. It also works for numeric values.

Task

From audi_cars extract cars with engine size (enginesize column) 1.5 and 2.9 using IN statement.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 5
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt