You are here: Re: query count help « PHP SQL « IT news, forums, messages
Re: query count help

Posted by MattMika on 01/04/06 01:28

Hilarion wrote:
> I'm not sure if your solution really works OK. As far as I can see
> it'll return as many rows for each order status as there are orders
> and this will make your script output something like:
>
> Pending - 1, Pending - 1, Pending - 1, Pending - 1, Processing - 1,
> Processing - 1, Processing - 1, Confirmed - 1, Confirmed - 1,
> Cancelled - 1
>
> So it'll work OK only for those statuses which have only one order
> (or have no orders, when it'll output "status name-0").

You are correct. After two weeks away from this I realized after adding many
orders for testing that this is exactly the case.

>
> I'd suggest using your script whith the query replaced by this one:
>
> SELECT
> os.status_id,
> os.status,
> COUNT( o.order_id ) AS num
> FROM
> orders_status AS os LEFT OUTER JOIN
> orders AS o ON o.order_status = os.status_id
> GROUP BY
> os.status_id,
> os.status
> ORDER BY
> os.status_id
>
> and line:
> $num = count($r["order_id"]);
> replaced with:
> $num = intval( $r['num'] );
>
>
>
> Hilarion

Thanx!

 

Navigation:

[Reply to this 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

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