Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 left join problem

Author  Topic 

drakull
Starting Member

12 Posts

Posted - 2001-07-02 : 16:45:31
i'm creating a news page with user comments, in the frontpage i want to list just the news and the number of comments of each news. i tried the query below:

SELECT news.id, news.tit, news.thenews, count(*) as newscomments
FROM news left join comments on news.id=news_id
GROUP BY news.id, news.tit, news.thenews
ORDER BY news.thedate DESC


The only problem here is that if the news doesn't have any comments, the totalcomments still returns 1.

thanks in advance!


----------
Henrique
   

- Advertisement -