Hi, i have a table with catagories and other is with records, i whant to write a query whitch returns catagories with records numbers.
I have wroted query like this:
kreoton wrote:Hi, i have a table with catagories and other is with records, i whant to write a query whitch returns catagories with records numbers.
I have wroted query like this:
SELECT C.cat_id,
C.cat_name,
C.cat_desc,
COUNT(R.rec_id)
FROM categories C, records R
WHERE R.cat_id = C.cat_id
GROUP BY (C.cat_id)
But this one returns only one catagory, how can i get all caegories?
P.S. Sorry for my English
Are you sure there is data for other catogories and records for them? if you have other catagories and no records you will need to left join to see them: