Hi,

> I've got two tables one is News items

> News_ID    News    etc...
> 1          Today in .....etc
> 2          Hello world .....etc
> 3          Blar di blar....etc
> 4          And now time for something else
> .
> .
> 100            The last thing

> and the other is comments on the news items (as well as other things on the
> web site)

> Type        Comment_ID        Comment  etc...
> News        1                 What about today then...
> News        1                 This is still today...........
> News        4                 This parot is dead......
> NotNews     4                 Hello..............

> What I am trying to get is one SELECT statment that will give me

> News_ID        News               Comment_Count  etc...
> 1                   Today in ...       2
> 2                   Hello world.       0
> 3                   Blar di blar        0
> 4                   And now ...etc  1


select news.newsid, news.news, count(comment.comment_id)
from news left join comment on news.newsid = comment.comment_id and comment.type = 
'News'
group by news.newsid, news.news;


Sasa



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to