MySQL Forums
Forum List  »  InnoDB

Re: Help needed on a small SELECT/JOIN statement
Posted by: Chris Farrugia
Date: November 04, 2005 03:19PM

I will be adding a table called comments with the following fields:

number - primary key, autonumber
author
id - same as authors.id
type - either article, news, etc.

So with that, I was thinking I could modify the above SQL in the following way:

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

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Help needed on a small SELECT/JOIN statement
1347
November 04, 2005 03:19PM


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.