- Alias without AS : You can assign an alias to a table without explicitly using the AS keyword. This is typically done to make the SQL query more readable or to simplify table references in complex queries. For example:
SELECT w.name, w.gender FROM wikitechytable w WHERE w.gender = 'male'
- In this query, "w" is an alias for the "wikitechytable" table. It allows you to refer to the table as "w" in the rest of the query, making the code more concise.
- Alias with AS: You can also use the AS keyword to assign an alias to a table. The following query is equivalent to the one above:
SELECT w.name, w.gender FROM wikitechytable AS w WHERE w.gender = 'male'
- Alias without AS : You can provide an alias for a column without using the AS keyword. This is often used to rename columns in the result set. For example:
SELECT id 'S. No' , name FullName, fees fee FROM wikitechytable
- In this query, "S.NO", “FullName” and "fee" are aliases for the "id", “name” and "fees " columns, respectively.
- Alias with AS : You can use the AS keyword to assign an alias to a column. This is the more common and widely accepted way of creating column aliases:
SELECT id AS 'S. No', name AS FullName, fees AS fee FROM wikitechytable