View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 09:48 AM
Stan R.
 
Posts: n/a
Default Re: Question about aliasing

Tigger wrote:
>
> Stan R. wrote:
>> Take this query I'm running from the mysql commandline:
>>

[...]example
>> 1) Why is it I can't use J0 and J1 in the definition for J_Diff and
>> J0_Pcnt, J1_Pcnt
>>
>> 2) Is there any way to do it that I'm missing here?
>>
>> I guess mainly I want ot save typing and it seems really redundant
>> and error prone to write a query the way I wrote it, and aliasing
>> seemed like it would make things less cluttered but all I get is
>> 'Unknown Column'
>>
>> Thanks for any help.

>
> You can't reference aliases in the field list or Where clauses.
>
> You can in the Having and Order By though.
>
> Tigger


Thank you. I could swear other DB engines allowed this. I remember doing
that sort of thing in Oracle a couple years ago. It seems to make so
much sense to me, to eliminate redundancy. Actualyl if MYsql allowed
subqueries the way Oracle did (like in the FROM list) this wouldn't be
an issue at all

--
Stan
Merry Christmas


Reply With Quote