AS Operator
The AS
operator is used to assign an alias to a table or column. Aliases make query results more readable and can simplify complex expressions.
Example: Using AS for Column Alias
SELECT Name AS 'Freedom Fighter', City AS 'Hometown'
FROM FreedomFighters;
Output:
Returns the names and cities with more descriptive column headers.
Do's and Don'ts
Do's
- Use
AS
to make your query results easier to understand. - Use meaningful aliases that clarify the purpose of the column.
Don'ts
- Don't use ambiguous or overly long aliases.
- Don't rely on aliases in complex queries without proper documentation.