Teddy A Jasin writes:

> Hi,
> I have this mysql statement:
> select hpnumber,count(*) as counts from Mobile_Ringtone_Manialogs
> where counts > 10 and datesent between '2001-09-24' and '2001-10-24' and 
> (returncode > 0 and returncode < 10) group by hpnumber order by counts DESC
> 
> and i Get this following error:
> Unknown column 'counts' in 'where clause'
> 
> why is that so??? it works before and now give me this problem.

If that worked before, something was very wrong. If you take a
look at how WHERE and GROUP BY work, you'll see that the grouping
is done _after_ it's known what rows there are to group and what
they should be grouped on. What you probably want to use is HAVING
for the 'counts = 10' part.

//C

-- 
 Carl Troein - Círdan / Istari-PixelMagic - UIN 16353280
 [EMAIL PROTECTED] | http://pixelmagic.dyndns.org/~cirdan/
 Amiga user since '89, and damned proud of it too.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to