Mysql As

Mysql As is used to specify the another name for the existing column and table name.

Mysql As

Mysql As

     

Mysql As is used to specify the another name for the existing column and table name. The Alias Name is helpful for database that makes it easy to write and read.

Understand with Example

This section of tutorial helps you to understand an example from 'Mysql As'. To understand this example we create a table 'stu'. The create table is used to create a table 'Stu' with required fieldname and data type respectively.

 

 

 

Create Table Stu

Create Table Stu(Id int,Name Varchar(15));

Insert values into Stu

Once your table is created,we use insert into statement that adds the records or rows to the table 'Stu'.

Insert Into Stu values(1,'Ajay');
Insert Into Stu values(2,'Bhanu');
Insert Into Stu values(3,'Komal');
Insert Into Stu values(4,'Rakesh');
Insert Into Stu values(5,'Santosh');

Stu

+----------+--------------+
| Icard_No | Student_Name |
+----------+--------------+
| 1        | Ajay         |
| 2        | Bhanu        |
| 3        | Komal        |
| 4        | Rakesh       |
| 5        | Santosh      |
+----------+--------------+

Query

The Query given below is used to assign alias name for the existing column and table. The as keyword is used for the alternative name of the column and table.In the given below query we use Id as alias name for Icard_No and name as Student_Name for the respective columns.  

Select Id as Icard_No, name as Student_Name from Stu;

Result

+----------+--------------+
| Icard_No | Student_Name |
+----------+--------------+
| 1        | Ajay         |
| 2        | Bhanu        |
| 3        | Komal        |
| 4        | Rakesh       |
| 5        | Santosh      |
+----------+--------------+