AS command in SQL - sql - sql tutorial - learn sql




Tags : sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

SQL Aliases:

  • SQL aliases are used to give a table, or a column in a table, a temporary name.
  • The keyword AS is used to assign an alias to the column or a table.
  • Aliases are often used to make column names more readable.
  • An alias only exists for the duration of the query.
  • It is inserted between the column name & the column alias or between the table name & the table alias.

Syntax:

Alias Column Syntax

SELECT column_name AS alias_name
FROM table_name;

Alias Table Syntax

SELECT column_name(s)
FROM table_name AS alias_name;
Tags : sql tutorial , pl sql tutorial , mysql tutorial , oracle tutorial , learn sql , sql server tutorial

Example:

  • Consider the following two tables.

Table 1 − Employee Table is as follows.

ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
6 Komal 22 MP 4500.00
7 Muffy 24 Indore 10000.00

Table 2 − ORDERS Table is as follows.

OID DATE Employee_ID AMOUNT
102 2009-10-08 00:00:00 3 3000
100 2009-10-08 00:00:00 3 1500
101 2009-11-20 00:00:00 2 1560
103 2008-05-20 00:00:00 4 2060
  • The following code block shows the usage of a table alias.
  • This would produce the following result.
ID NAME AGE AMOUNT
3 kaushik 23 3000
3 kaushik 23 1500
2 Khilan 25 1560
4 Chaitali 25 2060
  • Following is the usage of a column alias.
SQL> SELECT  ID AS Employee_NAME AS Employee_NAME
   FROM Employee
   WHERE SALARY IS NOT NULL;
  • This would produce the following result.
Employee_ID Employee_NAME
1 Ramesh
2 Khilan
3 kaushik
4 Chaitali
5 Hardik
6 Komal
7 Muffy

This tutorial provides more the basic needs and informations on sql tutorial , pl sql tutorial , mysql tutorial , sql server , sqlcode , sql queries , sql , sql formatter , sql join , w3schools sql , oracle tutorial , mysql , pl sql , learn sql , sql tutorial for beginners , sql server tutorial , sql query tutorial , oracle sql tutorial , t sql tutorial , ms sql tutorial , database tutorial , sql tutorial point , oracle pl sql tutorial , oracle database tutorial , oracle tutorial for beginners , ms sql server tutorial , sql tutorial pdf

Related Searches to AS command in SQL

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×