Function and AS

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

I am confused as to the use of "AS" in an SQL query.

For example, if I have this query:

SELECT MyTable.ID, MyFunction(MyTable.MyField) As MyReference
FROM MyTable
WHERE MyFunction(MyTable.MyField)=Criteria

What is the purpose of the "AS" in the query? I assumed it was to be used
as an alias to the function so that I could instead use:

SELECT MyTable.ID, MyFunction(MyTable.MyField) As MyReference
FROM MyTable
WHERE MyReference=Criteria

Is my assumption correct? Cause if it is, I can't get it to work.

Thanks
 
The "AS" serves as an alias for the field name in your example.

The WHERE clause cannot contain the alias to the field.
Think of it that Access has to apply the WHERE before it can decide whether
it needs to generate the field.
 
Back
Top