With SQL, aliases can be used for column names and table names.
The syntax is:
|
SELECT columnName AS columnAlias FROM tableName; |
The syntax is:
|
SELECT columnName FROM tableName AS tableAlias; |
This "Books" table:
|
Title |
Author |
Publisher |
Year |
|
الدورة الدموية |
إبن النفيس |
دار العلم |
1650 |
|
Java 2 |
L. Johnston |
Fast Press |
2002 |
|
Linux and Unix |
J. Sam |
Fast Press |
2004 |
|
Operating Systems |
M. Stone |
Coriolis |
2005 |
|
Web Programming |
K. Yariv |
East Edition |
2005 |
|
XML Language |
M. Salim |
Knowledge Press |
2000 |
And this SQL:
|
SELECT Title AS Book_Title, Year AS Publication_Year FROM Books; |
Returns this result:
|
Book_Title |
Publication_Year |
|
الدورة الدموية |
1650 |
|
Java 2 |
2002 |
|
Linux and Unix |
2004 |
|
Operating Systems |
2005 |
|
Web Programming |
2005 |
|
XML Language |
2000 |
The same "Books" table given above and this SQL:
|
SELECT Title, Author FROM Books AS Documents; |
Returns this result:
Table Documents:
|
Title |
Author |
|
الدورة الدموية |
إبن النفيس |
|
Java 2 |
L. Johnston |
|
Linux and Unix |
J. Sam |
|
Operating Systems |
M. Stone |
|
Web Programming |
K. Yariv |
|
XML Language |
M. Salim |
To test your SQL skills click here.