Jay Sprenkle <[EMAIL PROTECTED]> wrote:
It looks like CompId is the column name but you
place it second in your other query. The second name
in most SQL syntax is the alias, not the real column name.
What was an alias in SELECT becomes a column name in the resulting
VIEW. This is the whole point of alias in the first place.
They don't seem to be in the right order.
What does not seem to be in the right order? The syntax is
SELECT Expression AS Alias ...;
"AS" is optional, so one can equivalently write
SELECT Expression Alias ...;
When SELECT is used to create a VIEW, the corresponding column in the
view is named after the Alias:
CREATE VIEW v AS
SELECT Expression Alias ...;
SELECT Alias FROM v;
You don't need to create an alias explicitly to create a view.
You don't need to have aliases, but they are convenient when you want to
later refer to those columns. Especially if the column is an expression.
In any case, I never said that an alias was mandatory in this case. I'm
just pointing out that the OP's query is correct as written, which you
appeared to doubt.
Igor Tandetnik