Alias Error in a select statement

Alias Error in a select statement

am 26.03.2003 20:28:30 von rafarife

Description:
Hello,


When I run the following query:

Select Can as MiCantidad, MiCantidad * 2 from Stocks limit 10

I get the following error:

'The column 'MiCantidad' in field list is unknown'

So, Can I reference to a column by its alias in a
select statement?


Thanks in advance,
Rafa

How-To-Repeat:
Select Can as MiCantidad, MiCantidad * 2 from stocks limit 10

Fix:
-

Synopsis:optimizer bug in the index used by mysql/Innodb in the search

Submitter-Id:
Originator: Rafa
Organization: Pecomark
MySQL support: none
Severity: non-critical
Priority: medium
Category: mysqld-max-nt
Class: sw-bug
Release: mysqld 4.0.12

Exectutable: mysqld-max-nt
Environment: Pentium III-MMX, 500 MHZ, 540 MB
System: Windows 2000
Compiler: -
Architecture: i



____________________________________________________________ ______
Try AOL and get 1045 hours FREE for 45 days!
http://free.aol.com/tryaolfree/index.adp?375380

Get AOL Instant Messenger 5.1 for FREE! Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promos=380455

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: Alias Error in a select statement

am 26.03.2003 21:03:38 von Sinisa Milivojevic

rafarife@netscape.net writes:
> Description:
> Hello,
>
>
> When I run the following query:
>
> Select Can as MiCantidad, MiCantidad * 2 from Stocks limit 10
>
> I get the following error:
>
> 'The column 'MiCantidad' in field list is unknown'
>
> So, Can I reference to a column by its alias in a
> select statement?
>
>
> Thanks in advance,
> Rafa
>
> How-To-Repeat:
> Select Can as MiCantidad, MiCantidad * 2 from stocks limit 10

Hi!

This is not a bug.

You can not reference an alias in the select list.

You can do it freely in WHERE, ON , GROUP BY and other clauses.

--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: Alias Error in a select statement

am 26.03.2003 21:03:38 von Sinisa Milivojevic

rafarife@netscape.net writes:
> Description:
> Hello,
>
>
> When I run the following query:
>
> Select Can as MiCantidad, MiCantidad * 2 from Stocks limit 10
>
> I get the following error:
>
> 'The column 'MiCantidad' in field list is unknown'
>
> So, Can I reference to a column by its alias in a
> select statement?
>
>
> Thanks in advance,
> Rafa
>
> How-To-Repeat:
> Select Can as MiCantidad, MiCantidad * 2 from stocks limit 10

Hi!

This is not a bug.

You can not reference an alias in the select list.

You can do it freely in WHERE, ON , GROUP BY and other clauses.

--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
<___/ www.mysql.com



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: Alias Error in a select statement

am 26.03.2003 21:18:49 von miguel solorzano

At 22:03 26/03/2003 +0200, Sinisa Milivojevic wrote:
Hi Amigo,

>This is not a bug.
>
>You can not reference an alias in the select list.
>
>You can do it freely in WHERE, ON , GROUP BY and other clauses.

We have different behavior than M$ SQL server ? because it only
permit that with ORDER BY clause, not WHERE, GROUP BY and HAVING


--=20
Regards,
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Miguel Angel Sol=F3rzano
/ /|_/ / // /\ \/ /_/ / /__ S=E3o Paulo - Brazil
/_/ /_/\_, /___/\___\_\___/
<___/ www.mysql.com=20


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=3Dgcdmb-bugs@m.gmane.org

Re: Alias Error in a select statement

am 26.03.2003 23:18:24 von Paul DuBois

>rafarife@netscape.net writes:
>> Description:
>> Hello,
>>
>>    
>> When I run the following query:
>>
>> Select Can as MiCantidad, MiCantidad * 2 from Stocks limit 10
>>
>> I get the following error:
>>
>> 'The column 'MiCantidad' in field list is unknown'
>> 
>> So, Can I reference to a column by its alias in a
>> select statement?   
>>
>>
>> Thanks in advance,
>> Rafa
>>
>> How-To-Repeat:
>> Select Can as MiCantidad, MiCantidad * 2 from stocks limit 10
>
>Hi!
>
>This is not a bug.
>
>You can not reference an alias in the select list.
>
>You can do it freely in WHERE, ON , GROUP BY and other clauses.

Not quite...

Not in a WHERE clause. Well, table aliases, yes; column aliases, no.

>
>--
> __ ___ ___ ____ __
> / |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic
> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Fulltime Developer
>/_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus
> <___/ www.mysql.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org