We use cookies to enhance your experience on the site
CodeWorlds

SELECT in practice

You already know SELECT, FROM and the semicolon. Now we will practice combining them across different shelves. Everything you need you have already learned - here it is about fluency.

A single column

To take just one field, give its name after the

SELECT
keyword:

1SELECT nazwa FROM kategorie;

The Library will return a list of section names only - without the identifiers or other fields.

Several columns

We list columns separated by commas. The order in which you give them is the order in which they appear in the result:

1SELECT imie, nazwisko, email FROM czytelnicy;

This returns three fields for each reader.

The primary key is a column too

id
is an ordinary column - you can retrieve it just like any other:

1SELECT id, tytul FROM ksiazki;

Different shelves, the same syntax

The pattern is always the same:

SELECT columns FROM table;
. Only the shelf name and the list of fields change:

1SELECT data_wypozyczenia FROM wypozyczenia;
1SELECT imie, nazwisko, kraj FROM autorzy;

The more queries you write, the more this rhythm will become second nature. It is the foundation of the entire journey ahead!

Go to CodeWorlds