Column Aliases with AS
Sometimes column names aren't clear or you want to rename them in your output. Aliases let you give columns temporary names.
The AS Keyword
SELECT column_name AS alias_name FROM table_name;
The alias only affects the output - it doesn't change the actual column name in the database.
Exercises
Loading exercise...
Loading exercise...
Loading exercise...
Optional AS Keyword
In many SQL databases, the AS keyword is optional:
-- These are equivalent:
SELECT name AS username FROM users;
SELECT name username FROM users;
However, using AS makes your queries more readable.
Common Use Cases for Aliases
Aliases are helpful when:
- Column names are cryptic (e.g.,
usr_nmbecomesuser_name) - You're doing calculations (e.g.,
price * quantity AS total) - Column names would conflict in joins
- You want clearer output for reports
Loading exercise...
Free Practice
Loading SQL editor...
Experiment with:
- Aliases without the AS keyword
- Aliases with special characters (use double quotes)
- Mixing aliased and non-aliased columns
التالي · الدرس 5 من 27
WHERE Clause Basics
قراءة 1 دقيقة
أنهيت 4 من 27 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

