Docsity

SQL Alias - AS Keyword, Assignments of Database Programming

Toggle sidebar
bg1
SQL Alias -ASKeyword
Aliasis used to give an alias name to a table or a column,
which can be a resultset table too. This is quite useful in case
of large or complex queries. Alias is mainly used for giving a
short alias name for a column or a table with complex names.
Syntax of Alias for table names,
SELECT column-name FROM table-name AS alias-name
Following is an SQL query usingalias,
SELECT * FROM Employee_detail AS ed;
Syntax for defining alias for columnswill be like,
SELECT column-name AS alias-name FROM table-name;
Example using alias for columns,
SELECT customer_id AS cid FROM Emp;
Example of Alias in SQL Query
Consider the following two tables,
Theclasstable,
pf3
pf4

Partial preview of the text

Download SQL Alias - AS Keyword and more Assignments Database Programming in PDF only on Docsity!

SQL Alias - AS Keyword

Alias is used to give an alias name to a table or a column, which can be a resultset table too. This is quite useful in case of large or complex queries. Alias is mainly used for giving a short alias name for a column or a table with complex names. Syntax of Alias for table names, SELECT column-name FROM table-name AS alias-name Following is an SQL query using alias , SELECT * FROM Employee_detail AS ed; Syntax for defining alias for columns will be like, SELECT column-name AS alias-name FROM table-name; Example using alias for columns, SELECT customer_id AS cid FROM Emp;

Example of Alias in SQL Query

Consider the following two tables, The class table,

ID Name 1 abhi 2 adam 3 alex 4 anu 5 ashish and the class_info table, ID Address 1 DELHI

2 adam MUMBAI 3 alex CHENNAI SQL Alias seems to be quite a simple feature of SQL, but it is highly useful when you are working with more than 3 tables and have to use JOIN on them.