Sorry if it\'s trivial, but selecting column with *
sign isn\'t working always, and I don\'t find reference to this behavior.
I can select table A
-
The syntax diagram for select shows:
The outermost path of that shows the plain, unprefixed *
all-column wildcard on its own, and there is no loop back around for additional column expressions - all paths with a comma (to separate terms) are distinct from that plain *
path.
On the inner path that does allow a comma, and thus multiple expressions, you can only use .*
prefixed by a table/view/alias, and can then follow (or precede) that with other expressions.
(I really thought that was stated more clearly somewhere, but I can't find it anywhere in recent documentation...)
Why i must use the alias for * sign ?
select col,aa.* from A aa;
That isn't quite accurate; you don't have to use an alias, you can use the table name directly if it isn't aliased, so this is also valid:
select col,A.* from A;
There is a school of thought that you shouldn't use a wildcard anyway, at least for anything except an ad hoc query - it's better to list all of the required column name explicitly, prefixed with the appropriate table name/alias particularly if there is a join, for clarity and to avoid unexpected issues with tables being modified. That's rather outside the scope of this question though *8-)
- 热议问题