Difference between revisions of "Portable SQL/Common/Aliases"
From Linuxnetworks
(header hierarchy) |
m (Portable SQL - Aliases moved to Portable SQL/Common/Aliases) |
(No difference)
| |
Revision as of 16:26, 17 May 2007
Aliasing tables
Don't use the keyword "AS" between the table name and alias as no DBMS requires it and some don't recognize it. Instead, always write:
SELECT * FROM table t WHERE t.id = 0
Aliasing columns
Contrary to "Aliasing tables" the keyword "AS" between column name and alias is required by most database servers and should always be present:
SELECT count(*) AS cnt FROM table
Aliases for computed columns
The naming of computed columns implemented by the database servers is very different. Some name it like the computational expression ('count(*)'), most often in upper case and sometimes it isn't named at all. Therefore computed columns should be always given a name:
SELECT MAX(id) AS maxid FROM table
Back to Overview