Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Using the NOT Operator | Advanced Data Filtering
Introduction to SQL
course content

Course Content

Introduction to SQL

Introduction to SQL

1. Retrieving Data
2. Sorting Retrieved Data
3. Filtering Data
4. Advanced Data Filtering
5. Aggregate Functions

Using the NOT Operator

In order to cancel the condition, you need to use the keyword NOT. First, let’s look at the example:

123
SELECT name, capital FROM country WHERE NOT continent='Asia';
copy

Explanation: The NOT operator rejects the condition here; hence, it matches the continent to anything that is not Asia.

Task

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.

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.

Here's a short example of the country table:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

Task

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.

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.

Here's a short example of the country table:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 4. Chapter 5
toggle bottom row

Using the NOT Operator

In order to cancel the condition, you need to use the keyword NOT. First, let’s look at the example:

123
SELECT name, capital FROM country WHERE NOT continent='Asia';
copy

Explanation: The NOT operator rejects the condition here; hence, it matches the continent to anything that is not Asia.

Task

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.

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.

Here's a short example of the country table:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

Task

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.

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.

Here's a short example of the country table:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 4. Chapter 5
toggle bottom row

Using the NOT Operator

In order to cancel the condition, you need to use the keyword NOT. First, let’s look at the example:

123
SELECT name, capital FROM country WHERE NOT continent='Asia';
copy

Explanation: The NOT operator rejects the condition here; hence, it matches the continent to anything that is not Asia.

Task

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.

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.

Here's a short example of the country table:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

Task

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.

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.

Here's a short example of the country table:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

In order to cancel the condition, you need to use the keyword NOT. First, let’s look at the example:

123
SELECT name, capital FROM country WHERE NOT continent='Asia';
copy

Explanation: The NOT operator rejects the condition here; hence, it matches the continent to anything that is not Asia.

Task

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.

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.

Here's a short example of the country table:

idnamecontinentregionsurfaceareacapitalpopulation
1JapanAsiaEastern Asia377829Tokyo126714000
2LatviaEuropeNULL64589Riga2424200
3MexicoNorth AmericaCentral America1958201Mexico City98881000
.....................
15MaltaEuropeSouthern Europe316Valletta380200

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 4. Chapter 5
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt