Reply to Re: using conditional statements in where-clause

Your name:

Reply:


Posted by Tim Roberts on 02/02/07 06:40

"Captain Paralytic" <paul_lautman@yahoo.com> wrote:

>
>
>On 30 Jan, 13:56, "pwieg...@gmail.com" <pwieg...@gmail.com> wrote:
>> Hi,
>>
>> I'm trying to use the result of a conditional statement in a where
>> clause, but i'm getting 1)nowhere 2) desperate :-)
>>
>> The query is simple:
>> --------
>> SELECT
>> idUser,
>> (@ageraw:=YEAR(CURRENT_DATE()) - YEAR(dateofbirth) -
>> (RIGHT(CURRENT_DATE(),5)<'12-31')) AS temp,
>> @age:=if( @ageraw > 100,0,
>> if( @ageraw < 10,0 ,
>> @ageraw
>> )) as age
>> from users u
>> ---------
>>
>> this works as a charm. But now I want to select users of a certain
>> age, and I add a where clause:
>> from users u having @age<50
>>
>> This is not working. Nor is any other variant I can think of. How can
>> this be achieved?
>>
>> greeting, and many thanks,
>>
>> Paul
>
>I would have expected it to be
>from users u having age<50

Ummm, why isn't it "FROM users u WHERE age<50"? Do you have a GROUP BY
clause that you didn't show us? HAVING is only used with GROUP BY.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация