|
Home > Archive > MySQL Server Forum > June 2005 > Query help: Get category and number of items in one query
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Query help: Get category and number of items in one query
|
|
| mfyahya@gmail.com 2005-06-25, 3:23 am |
| Hi,
I have a `category` table with columns cat_id and cat_name. And another
`items` table with columns item_id, item_name and cat_id.
I want a query which will select display each category name and the
number of items in that category. I could do this in two sql
statements, is it possible to do it in one?
Thanks~
| |
| Bill Karwin 2005-06-26, 3:23 am |
| mfyahya@gmail.com wrote:
> Hi,
> I have a `category` table with columns cat_id and cat_name. And another
> `items` table with columns item_id, item_name and cat_id.
> I want a query which will select display each category name and the
> number of items in that category. I could do this in two sql
> statements, is it possible to do it in one?
Look up GROUP_CONCAT in the MySQL reference documentation.
Also see this thread on this newsgroup from a couple of weeks back:
http://groups-beta.google.com/group...1350b921027cc2/
Regards,
Bill K.
|
|
|
|
|