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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count() that returns 0 does not display 1

Status
Not open for further replies.

autumnEND

Programmer
Nov 1, 2005
61
GB
Hello, ive been searching for a sulution to this but havent seen one anywhere.

I want to display a news post, and next to it, the number of comments it has

I have two tables, one for news post (news) and another for news comments(news_comments).

the only problem is that if the news post does not have news comments, I STILL want to display it on the page

The problem is that if the count(*) is equal to zero, the row is not returned

SELECT COUNT(nc.newsID) AS num_comments, n.newsID, n.newsDATE, n.newsTITLE, n.newsARTICLE, n.newsPOSTEDBY
FROM news_comments AS nc INNER JOIN
news AS n ON nc.newsID = n.newsID
GROUP BY n.newsID, n.newsDATE, n.newsTITLE, n.newsARTICLE, n.newsPOSTEDBY
HAVING(COUNT(*) >=0)

is there any way to display the record even if the count = 0

any help would be appreciated thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top