Reply to Re: Sort array from a Query

Your name:

Reply:


Posted by bettina on 11/29/05 23:25

I've tried the following:

$search_breweries = mysql_query("SELECT b.BREWERY_CODE, b.BREWERY,
COUNT(c.ID) FROM breweries as b JOIN coasters as c ON
b.BREWERY_CODE = c.BREWERY_CODE Group by b.BREWERY_CODE order by
COUNT(c.ID) DESC ");
$i = 0;
while ($row = mysql_fetch_array($search_breweries, MYSQL_NUM))
{
$mybreweries[$i][0] = $row[0];
$mybreweries[$i][1] = $row[1];
$mybreweries[$i][2] = $row[2];
$i = $i + 1;
}
......
And I get the following message:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in....


Sean schrieb:

> Follow this up in the sql forums, but you want something like this:
>
> SELECT b.BREWERY_CODE, b.BREWERY, COUNT(c.id) as num_coaster
> FROM breweries b LEFT JOIN coasters c ON b.BREWERY_CODE =
> c.BREWERY_CODE
> Group by b.BREWERY_CODE
> order by COUNT(c.id) DESC
>
> UNTESTED!
>
> This will get you what you want in one pass. (i think)

[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

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