Conteúdo do Curso
SQL Basics
SQL Basics
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,
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
WHERE column IN ('value1', 'value2')
is equvivalent toWHERE column = 'value1' OR column = 'value2'
. It also works for numeric values.
Swipe to show code editor
From audi_cars
extract cars with engine size (enginesize
column) 1.5 and 2.9 using IN
statement.
Obrigado pelo seu feedback!
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,
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
WHERE column IN ('value1', 'value2')
is equvivalent toWHERE column = 'value1' OR column = 'value2'
. It also works for numeric values.
Swipe to show code editor
From audi_cars
extract cars with engine size (enginesize
column) 1.5 and 2.9 using IN
statement.
Obrigado pelo seu feedback!
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,
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
WHERE column IN ('value1', 'value2')
is equvivalent toWHERE column = 'value1' OR column = 'value2'
. It also works for numeric values.
Swipe to show code editor
From audi_cars
extract cars with engine size (enginesize
column) 1.5 and 2.9 using IN
statement.
Obrigado pelo seu feedback!
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,
SELECT * FROM audi_cars WHERE model IN ('A4', 'A5')
WHERE column IN ('value1', 'value2')
is equvivalent toWHERE column = 'value1' OR column = 'value2'
. It also works for numeric values.
Swipe to show code editor
From audi_cars
extract cars with engine size (enginesize
column) 1.5 and 2.9 using IN
statement.