Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Related Tutorials


 
 

Share on Google+Share on Google+

Mysql As

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

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      |
+----------+--------------+
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 17, 2009

Related Tutorials

Discuss: Mysql As  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:4
Jonathon
June 14, 2011
typo?

Hey, I think you have a typo in this example. The first table that you print out should have ID for the column name, not Icard_No, and should have Name, not Student_Name. It just looks like you might have accidentally copied and pasted the wrong thing.
Somebody
February 28, 2012
Error correction

The first table you showed should have a column named "Id", not "Icard_No". The second table, however, is correct
sumduu
May 2, 2012
thanx

thanx dear
silverham
September 9, 2012
wrong table first table

The first table shown should be: +------+---------+ | Id | Name | +------+---------+ | 1 | Ajay | | 2 | Bhanu | | 3 | Komal | | 4 | Rakesh | | 5 | Santosh | +------+---------+ Otherwise GREAT article, step by step is good.
DMCA.com