On 3 Sep, 16:16, howa <howac...@gmail.com> wrote:
> Consider a query like, e.g.
>
> SELECT GROUP_CONCAT(id) FROM `products` GROUP BY `brand`;
>
> Then the result will be product id string group by brand name
>
> However, I want to limit the GROUP_CONCAT() only return the top 3
> products of each brand, say, by price
>
> How to do this?
>
> Thanks.
There are just SO MANY answers around to this already!
I just Googled "mysql top n group" and got a massive list.
Here's a link to the first one:
http://thenoyes.com/littlenoise/?p=36
Amazed you couldn't do this too!