MySQL Forums
Forum List  »  InnoDB

Re: Help needed on a small SELECT/JOIN statement
Posted by: Jay Pipes
Date: November 04, 2005 01:11PM

Because only one has been viewed. To remedy, use a LEFT JOIN:

SELECT a.id, a.title, a.summary, a.dateposted, COUNT(*) as num_views
FROM articles a
LEFT JOIN views v ON a.id = v.id
GROUP BY a.id
ORDER BY a.dateposted DESC
LIMIT 0,10

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Help needed on a small SELECT/JOIN statement
1663
November 04, 2005 01:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.