NOT LIKE
In the previous section, we discussed and saw examples of using the LIKE
operator and how the use of wildcards that provide for robust filtering
based on patterns. In this section, we look at an example of NOT LIKE.
We know by now the NOT operators simply returns all records that
evaluated to false in a given condition.
Let's demonstrate an example of NOT LIKE by
filtering for which customers are from countries with very short names
(3 characters or less). The query to implement this looks like below:
select *
from customers
where country NOT like '____%'
As we expect, the output will only contain customers that have country
names with 3 or less characters.
Let's demonstrate an example of NOT LIKE by
filtering for which customers are from countries with very long names (6
characters or less). The query to implement this looks like below:
select *
from customers
where country NOT like '_____%'
The difference here is that we are saying we want to eliminate any
customer_id with two or more digits. This will effectively always return
single digits ids.
This concludes our discussion on the NOT LIKE operator.