SQL Aliases
Ususally in database tables and columns can have long names. When you work with multiple tables, you should write the name of the column with the name of the table to define the column, for example, users.user_id
and messages.date_created
. To avoid overtyping, in SQL we use Aliases. They allow us to give temporary names to column or tables.
For example, for our table:
123SELECT album, singer as some_label FROM songs as t WHERE t.album = 'The Dark Side of the Moon' OR t.singer = 'Mushmellow'
Here you use table songs
as t
. In the console, instead of singer
, your column has a label some_label
. This example is not demonstrative enough, but in the next section we'll work with multiple tables, and temporary names may be useful.
Swipe to start coding
Find top-3 newest songs, their singers, and years, but use songs
table as s
. Make the column title
displayed with the label name
.
Løsning
Takk for tilbakemeldingene dine!
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Oppsummer dette kapittelet
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 4.17
SQL Aliases
Sveip for å vise menyen
Ususally in database tables and columns can have long names. When you work with multiple tables, you should write the name of the column with the name of the table to define the column, for example, users.user_id
and messages.date_created
. To avoid overtyping, in SQL we use Aliases. They allow us to give temporary names to column or tables.
For example, for our table:
123SELECT album, singer as some_label FROM songs as t WHERE t.album = 'The Dark Side of the Moon' OR t.singer = 'Mushmellow'
Here you use table songs
as t
. In the console, instead of singer
, your column has a label some_label
. This example is not demonstrative enough, but in the next section we'll work with multiple tables, and temporary names may be useful.
Swipe to start coding
Find top-3 newest songs, their singers, and years, but use songs
table as s
. Make the column title
displayed with the label name
.
Løsning
Takk for tilbakemeldingene dine!
Awesome!
Completion rate improved to 4.17single