If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Question about Aliasing?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-26-05, 10:08
hristo hristo is offline
Registered User
 
Join Date: Dec 2004
Posts: 3
Exclamation Question about Aliasing?

Heya,

While reading about aliasing using two different references, one author states that the aliasing is annotated using the key AS like in:
select...
FROM Emp as E1;

but in the other reference, the author states the key AS is not necessary, so the above query can be written instead as follows:
select...
FROM Emp E1

i am just wondering which one is correct? what MySQL/Oracle supports?

Many thanks
Reply With Quote
  #2 (permalink)  
Old 02-26-05, 10:56
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
which one is correct depends on which database you're using

off the top of my head i can't remember which one requires AS (as opposed to it being optional)

besides, the sql reads better with AS, so i always throw it in, consequently i never get the syntax error when it's missing

helps?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-26-05, 12:17
derrickleggett derrickleggett is offline
Registered User
 
Join Date: Apr 2004
Location: Kansas City, MO
Posts: 734
It works either way in Oracle or SQL Server. I'm not sure about mySQL. You're always safe using AS.
__________________
MeanOldDBA
derrickleggett@hotmail.com
When life gives you a lemon, fire the DBA.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On