Skip to content
Advertisement

what is the difference between naming a subquery vs using AS to alias the subquery result?

Is there any difference between these two syntaxes?

select * from (some query) result
select * from (some query) AS result

Advertisement

Answer

There is no functional difference between the two (they do the same thing).

However some databases have a preference one way or the other. For instance, Oracle does not support as for table aliases. On the other hand, MS Access requires them.

Personally, I only use as for column aliases. I use them for column aliases because it is very easy to leave out a column, so:

select x y

works even when you mean:

select x, y

The as is a statement of intent for column aliases.

There is no danger of such confusing in the from clause, so I find that as for table aliases is unnecessary.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement