Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two tables joined, need count of joins

Status
Not open for further replies.

imstillatwork

IS-IT--Management
Sep 26, 2001
1,605
US
here is my simple two tables joined.
Code:
SELECT
 l.id AS lid
 ,l.title AS ltitle

 ,c.id AS cid
 ,c.title AS ctitle

FROM links AS l
LEFT JOIN category AS c
ON c.id = l.category_id

Without a subquery (mysql 4.0.16, hosted) how can I coun the links per category?

Thanks, I'm sure r937 will have a deliciously elegant way to make this work :)







 
Code:
select c.id      as cid
     , c.title   as ctitle
     , count(l.category_id) as links
  from category as c
left outer
  join links as l
    on c.id = l.category_id 
group
    by c.id  
     , c.title

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top