Friday, 16 December 2011

SQL Alias



You can give a table or a column another name by using an alias


Syntax 

SELECT column_name AS alias_name
FROM table_name AS alias_name



The "custmast" table




custcode
custname
city
qty
rate
1
Siva
Srivilliputtur
50
70
2
Bala
Sivakasi
30
56
3
Kanna
Madurai
100
200
4
Vijay
Chennai
30
30
5
Kodee
Sandnes
60
80
5
Kodee
Srivilliputtur
60
30



Example 


Select cm.custcode as Ccode,cm.custname as Cname from custmast as cm where cm.custcode=1


Output

Ccode
Cname
1
Siva

No comments:

Post a Comment


”Back