Course Content
Introduction to SQL
Introduction to SQL
Using the NOT Operator
In order to cancel the condition, you need to use the keyword NOT
.
The NOT
operator is essential when you want to exclude certain records from your query results. It allows you to specify conditions that should not be met, effectively filtering out unwanted data. This can be particularly useful in scenarios where you need to focus on a subset of data that does not meet specific criteria.
First, let’s look at the syntax:
Now let's look at the example:
SELECT name, capital FROM country WHERE NOT continent='Asia';
Explanation: The NOT
operator rejects the condition here; hence, it matches the continent to anything that is not Asia.
Here is the country
table we are working with:
Swipe to show code editor
Write an SQL query to get the name
and capital
columns from the country
table (please retrieve these columns in this order). These countries must be not from the 'South America' continent
.
Note
Pay attention to the fact that the names of the continents begin with a capital letter and not a lowercase one; this is very important.
Thanks for your feedback!
Using the NOT Operator
In order to cancel the condition, you need to use the keyword NOT
.
The NOT
operator is essential when you want to exclude certain records from your query results. It allows you to specify conditions that should not be met, effectively filtering out unwanted data. This can be particularly useful in scenarios where you need to focus on a subset of data that does not meet specific criteria.
First, let’s look at the syntax:
Now let's look at the example:
SELECT name, capital FROM country WHERE NOT continent='Asia';
Explanation: The NOT
operator rejects the condition here; hence, it matches the continent to anything that is not Asia.
Here is the country
table we are working with:
Swipe to show code editor
Write an SQL query to get the name
and capital
columns from the country
table (please retrieve these columns in this order). These countries must be not from the 'South America' continent
.
Note
Pay attention to the fact that the names of the continents begin with a capital letter and not a lowercase one; this is very important.
Thanks for your feedback!
Using the NOT Operator
In order to cancel the condition, you need to use the keyword NOT
.
The NOT
operator is essential when you want to exclude certain records from your query results. It allows you to specify conditions that should not be met, effectively filtering out unwanted data. This can be particularly useful in scenarios where you need to focus on a subset of data that does not meet specific criteria.
First, let’s look at the syntax:
Now let's look at the example:
SELECT name, capital FROM country WHERE NOT continent='Asia';
Explanation: The NOT
operator rejects the condition here; hence, it matches the continent to anything that is not Asia.
Here is the country
table we are working with:
Swipe to show code editor
Write an SQL query to get the name
and capital
columns from the country
table (please retrieve these columns in this order). These countries must be not from the 'South America' continent
.
Note
Pay attention to the fact that the names of the continents begin with a capital letter and not a lowercase one; this is very important.
Thanks for your feedback!
In order to cancel the condition, you need to use the keyword NOT
.
The NOT
operator is essential when you want to exclude certain records from your query results. It allows you to specify conditions that should not be met, effectively filtering out unwanted data. This can be particularly useful in scenarios where you need to focus on a subset of data that does not meet specific criteria.
First, let’s look at the syntax:
Now let's look at the example:
SELECT name, capital FROM country WHERE NOT continent='Asia';
Explanation: The NOT
operator rejects the condition here; hence, it matches the continent to anything that is not Asia.
Here is the country
table we are working with:
Swipe to show code editor
Write an SQL query to get the name
and capital
columns from the country
table (please retrieve these columns in this order). These countries must be not from the 'South America' continent
.
Note
Pay attention to the fact that the names of the continents begin with a capital letter and not a lowercase one; this is very important.