Field names on a shelf can be technical:
rok_wydania, autor_id. In the result we can rename them into something friendlier for the reader - this is an alias.We create aliases with the word AS:
1SELECT tytul AS Tytul, cena AS Cena FROM ksiazki;In the answer the column headers will read Tytul and Cena, even though on the shelf they are still called
tytul and cena. An alias changes only the label in the result - it never touches the data.If an alias is to contain a space, wrap it in quotes:
1SELECT rok_wydania AS "Rok wydania" FROM ksiazki;MySQL lets you drop the word
AS - a single space is enough:1SELECT nazwisko Autor FROM autorzy;It works the same, but with
the code is clearer - and that is what I recommend, @name.AS
JOIN) and functions.Remember: an alias is a nickname given to a field for the span of a single query.