Course Content
SQL Basics
SQL Basics
NOT like this!
Often situation when we know what we don't want to find. In the case of numeric value, you should already know, that there is <>
sign in SQL which means not equal. This also works for non-numeric columns: you can easily set <> 'some word'
condition. But what if we want to avoid multiple non-numeric values? Or avoid some pattern?
Of course, it's already solved! There is NOT
statement in SQL, which can be used with LIKE
and IN
statements. For example, we can filter cars in audi_table
so there won't be Q-series cars.
SELECT * FROM audi_cars WHERE model NOT LIKE 'Q%'
Please note, that
NOT
should be placed beforeIN
orLIKE
, like in spelling.
Task
Extract all the cars from the audi_cars
table except A3, A4, and Q3 models.
Thanks for your feedback!
NOT like this!
Often situation when we know what we don't want to find. In the case of numeric value, you should already know, that there is <>
sign in SQL which means not equal. This also works for non-numeric columns: you can easily set <> 'some word'
condition. But what if we want to avoid multiple non-numeric values? Or avoid some pattern?
Of course, it's already solved! There is NOT
statement in SQL, which can be used with LIKE
and IN
statements. For example, we can filter cars in audi_table
so there won't be Q-series cars.
SELECT * FROM audi_cars WHERE model NOT LIKE 'Q%'
Please note, that
NOT
should be placed beforeIN
orLIKE
, like in spelling.
Task
Extract all the cars from the audi_cars
table except A3, A4, and Q3 models.
Thanks for your feedback!
NOT like this!
Often situation when we know what we don't want to find. In the case of numeric value, you should already know, that there is <>
sign in SQL which means not equal. This also works for non-numeric columns: you can easily set <> 'some word'
condition. But what if we want to avoid multiple non-numeric values? Or avoid some pattern?
Of course, it's already solved! There is NOT
statement in SQL, which can be used with LIKE
and IN
statements. For example, we can filter cars in audi_table
so there won't be Q-series cars.
SELECT * FROM audi_cars WHERE model NOT LIKE 'Q%'
Please note, that
NOT
should be placed beforeIN
orLIKE
, like in spelling.
Task
Extract all the cars from the audi_cars
table except A3, A4, and Q3 models.
Thanks for your feedback!
Often situation when we know what we don't want to find. In the case of numeric value, you should already know, that there is <>
sign in SQL which means not equal. This also works for non-numeric columns: you can easily set <> 'some word'
condition. But what if we want to avoid multiple non-numeric values? Or avoid some pattern?
Of course, it's already solved! There is NOT
statement in SQL, which can be used with LIKE
and IN
statements. For example, we can filter cars in audi_table
so there won't be Q-series cars.
SELECT * FROM audi_cars WHERE model NOT LIKE 'Q%'
Please note, that
NOT
should be placed beforeIN
orLIKE
, like in spelling.
Task
Extract all the cars from the audi_cars
table except A3, A4, and Q3 models.