473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Query help: Get category and number of items in one query

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~

Jul 23 '05 #1
1 1457
mf*****@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/...350b921027cc2/

Regards,
Bill K.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
0
by: Frank | last post by:
This one has me pretty stumped at the moment. I've tried variations with MySQL IF() statements but can't quite get it right. How can I select all of the records of the table 'items' that are...
4
by: frizzle | last post by:
Hi there, Still building my forum. I have a certain mysql-query i just can't figure out. These are my tables (simplified): categories -> id, description forums -> id, cat_id,...
7
by: Barkster | last post by:
I'm trying to list my categories and how many items are in each category. I'm not much on sub queries. How can I combine these two items. I'd like to display the category and the corresponding...
2
by: audiophilechris | last post by:
Can anyway help me write this query? I've created a DB to help me manage delivery logistics for items I rent out. I have a table that i use to record delivery date, delivery time, pickup date,...
5
by: Nobody | last post by:
I'm trying to write a stored proc... Basically, I have a tblItems table which contains a list of every item available. One of the columns in this table is the brand... for test purposes, I...
4
by: Smiley | last post by:
I want to use one query but apply it to 4 different forms. So if Category field = 1 then only display items with Category =1 on form1, if Category = 2, all items with category = 2 display on form...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
1
by: neha02 | last post by:
Hi all, this is my first post here although i've always referred this forum for help. I am trying to design a query based on 4 queries but i'm unable to get the result i want. Please help me-...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.