Concept Flow - Column aliases with AS
Write SELECT statement
Specify column names
Use AS to rename columns
Execute query
Result shows new column names
This flow shows how to rename columns in a query result using AS, making output easier to read.
SELECT first_name AS Name, age AS AgeYears FROM users;
| Step | Action | Input | Output |
|---|---|---|---|
| 1 | Start query execution | SELECT first_name AS Name, age AS AgeYears FROM users; | Prepare to read users table |
| 2 | Read first row from users | Row: {first_name: 'Alice', age: 30} | Apply aliases: Name='Alice', AgeYears=30 |
| 3 | Read second row from users | Row: {first_name: 'Bob', age: 25} | Apply aliases: Name='Bob', AgeYears=25 |
| 4 | Read third row from users | Row: {first_name: 'Carol', age: 27} | Apply aliases: Name='Carol', AgeYears=27 |
| 5 | No more rows | End of table | Return result set with aliased columns |
| Variable | Start | After 1 | After 2 | After 3 | Final |
|---|---|---|---|---|---|
| Name | N/A | Alice | Bob | Carol | Carol |
| AgeYears | N/A | 30 | 25 | 27 | 27 |
SELECT column_name AS alias_name Use AS to rename columns in query output. Aliases improve readability without changing table. Alias names appear in result headers. AS keyword is optional but recommended for clarity.