Re: Sort array from a Query
- From: bettina@xxxxxxxxxx
- Date: 29 Nov 2005 13:53:54 -0800
Thank you. Now it works. I wrote like that:
$search_breweries = mysql_query("SELECT b.BREWERY_CODE, b.BREWERY,
COUNT(c.ID) as cant FROM breweries as b JOIN coasters as c ON
b.BREWERY_CODE = c.BREWERY_CODE Group by b.BREWERY_CODE order by cant
DESC ");
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)
.
- References:
- Sort array from a Query
- From: bettina
- Re: Sort array from a Query
- From: Sean
- Sort array from a Query
- Prev by Date: Re: Sort array from a Query
- Next by Date: Re: Error log.
- Previous by thread: Re: Sort array from a Query
- Next by thread: setting up a A/B split test with PHP
- Index(es):
Relevant Pages
|