Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Retrieving Multiple Columns | Retrieving Data
Introduction to SQL
course content

Kursinnhold

Introduction to SQL

Introduction to SQL

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

book
Retrieving Multiple Columns

Inspecting the Table

Let's delve deeper into the country database. This database contains a single table, also named country. We'll take a closer look at the data within this table.

This table contains 15 rows, representing 15 unique records for various countries.

Now, let's discuss the columns. The table includes 7 columns: id, name, continent, region, SurfaceArea, capital, and population.

  1. id - the unique identifier for each record;

  2. name - the name of the country;

  3. continent - the continent where the country is located;

  4. region - the specific region within the continent;

  5. SurfaceArea - the total land area of the country;

  6. capital - the capital city of the country;

  7. population - the number of people living in the country.

The Syntax for Selecting Multiple Columns

To retrieve multiple columns, use the SELECT statement. After SELECT, list the column names you want to retrieve, separated by commas.

The syntax looks like this:

sql

Here's an example of how to select three columns from the country table:

12
SELECT id, name, capital FROM country;
copy

Here's a short example of the country table:

Oppgave

Swipe to start coding

Write an SQL query to retrieve the continent and population columns from the country table.

Note

Remember that columns must be separated by commas!

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 2
toggle bottom row

book
Retrieving Multiple Columns

Inspecting the Table

Let's delve deeper into the country database. This database contains a single table, also named country. We'll take a closer look at the data within this table.

This table contains 15 rows, representing 15 unique records for various countries.

Now, let's discuss the columns. The table includes 7 columns: id, name, continent, region, SurfaceArea, capital, and population.

  1. id - the unique identifier for each record;

  2. name - the name of the country;

  3. continent - the continent where the country is located;

  4. region - the specific region within the continent;

  5. SurfaceArea - the total land area of the country;

  6. capital - the capital city of the country;

  7. population - the number of people living in the country.

The Syntax for Selecting Multiple Columns

To retrieve multiple columns, use the SELECT statement. After SELECT, list the column names you want to retrieve, separated by commas.

The syntax looks like this:

sql

Here's an example of how to select three columns from the country table:

12
SELECT id, name, capital FROM country;
copy

Here's a short example of the country table:

Oppgave

Swipe to start coding

Write an SQL query to retrieve the continent and population columns from the country table.

Note

Remember that columns must be separated by commas!

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 2
Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Vi beklager at noe gikk galt. Hva skjedde?
some-alt