Re: Sort array from a Query



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)

.



Relevant Pages

  • Re: Sort array from a Query
    ... COUNTas cant FROM breweries as b JOIN coasters as c ON ... Sean schrieb: ... > Follow this up in the sql forums, but you want something like this: ...
    (comp.lang.php)
  • Re: Sort array from a Query
    ... COUNTFROM breweries as b JOIN coasters as c ON ... result resource in.... ... Prev by Date: ...
    (comp.lang.php)