Tables aliases
As for columns, you can also assign some alias to the table name. It is very useful when you work with multiple tables at once, as they may have identical names.
To assign an alias to a table name use the same syntax as for columns. For example,
12SELECT column1, column2 FROM table_name AS t
With this technique, you can refer to certain columns by using alias.column
. It also works for the whole table name. For example,
12SELECT t.column1, t.column2 FROM table_name AS t
and
12SELECT table_name.column1, table_name.column2 FROM table_name
queries will return the same result. It's all about usability.
Swipe to start coding
Extract columns model
, price
, fueltype
, and mpg
from audi_cars
table. Use a
alias for the table and extract columns using this alias. Print first 10 rows.
Løsning
Tak for dine kommentarer!
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Awesome!
Completion rate improved to 2.63Awesome!
Completion rate improved to 2.63
Tables aliases
As for columns, you can also assign some alias to the table name. It is very useful when you work with multiple tables at once, as they may have identical names.
To assign an alias to a table name use the same syntax as for columns. For example,
12SELECT column1, column2 FROM table_name AS t
With this technique, you can refer to certain columns by using alias.column
. It also works for the whole table name. For example,
12SELECT t.column1, t.column2 FROM table_name AS t
and
12SELECT table_name.column1, table_name.column2 FROM table_name
queries will return the same result. It's all about usability.
Swipe to start coding
Extract columns model
, price
, fueltype
, and mpg
from audi_cars
table. Use a
alias for the table and extract columns using this alias. Print first 10 rows.
Løsning
Tak for dine kommentarer!
single
Awesome!
Completion rate improved to 2.63
Tables aliases
Stryg for at vise menuen
As for columns, you can also assign some alias to the table name. It is very useful when you work with multiple tables at once, as they may have identical names.
To assign an alias to a table name use the same syntax as for columns. For example,
12SELECT column1, column2 FROM table_name AS t
With this technique, you can refer to certain columns by using alias.column
. It also works for the whole table name. For example,
12SELECT t.column1, t.column2 FROM table_name AS t
and
12SELECT table_name.column1, table_name.column2 FROM table_name
queries will return the same result. It's all about usability.
Swipe to start coding
Extract columns model
, price
, fueltype
, and mpg
from audi_cars
table. Use a
alias for the table and extract columns using this alias. Print first 10 rows.
Løsning
Tak for dine kommentarer!