Reply to Re: using mysql count

Your name:

Reply:


Posted by Christoph Burschka on 11/20/06 17:27

Auddog wrote:
> I have the following query that works in mysql:
>
> select id, order_no, price, count(item_no), sum(price) from production
> WHERE item_no = '27714'
> group by item_no;
>
> When I setup my query in php, I use:
>
> $query2 = "SELECT id, order_no, price, count(item_no) as count from
> production where item_no = '27714";
>
> I keep getting an error in on my php page:
>
> Warning: mysqli_error() expects exactly 1 parameter, 0 given in
> c:\Inetpub\wwwroot\production\production_line_daily.php on line 24
> Error in query: SELECT id, order_no, price, count(item_no) as count from
> production where item_no = '27714'.
>
> If I remove the count(item_no) as count from the query - it works fine. I
> really want to put the count in though. And eventually the sum.
>
> Any help that you can provide is greatly appreciated.
>
> A
>
>

It looks like you didn't copy the whole query. It's cut off after '27714. Note
also the missing single quote at the end.

To make it work correctly, copy the complete query - including the "group by
item_no". Without a GROUP BY clause, as MySQL likes to inform you, "mixing of
GROUP columns with non-GROUP columns is illegal".


--
Christoph Burschka

[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

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