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

Kursusindhold

SQL Basics

SQL Basics

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

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

Opgave

Swipe to start coding

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

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 5
toggle bottom row

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

Opgave

Swipe to start coding

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

Løsning

Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 5
Switch to desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Vi beklager, at noget gik galt. Hvad skete der?
some-alt