Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About using AS...

Status
Not open for further replies.

SFiend

Programmer
Jun 4, 2004
39
CZ
I don't know why, but this is not available :(

select A, (A*B) as C, (C*D) as E ........

Can you help me?

Do I have to use:

select A, (A*B) as C, ((A*B)*D) as E ........
 
You have to use the latter.

According to the MySQL online manual aliases created with AS can be use in a SELECT statement's GROUP BY, ORDER BY and HAVING clauses.

But to the best of my knowledge they can't be used within the columns specification clause of a SELECT statement.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Because ..

If you think about HOW MySQL does the work, the "SELECT [fieldlist] FROM tblName WHERE [clause]" is all parsed in one shot.

Until it gets to the end of the SELECTing phase it doesn't know about any renaming that is going on in the middle of it.

Only after the SELECTing is done does it go on to consider GROUPing, HAVing and ORDERing tasks. By then it knows of the new column names - so they can then be used.





'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top