|
Posted by Stefan Rybacki on 07/24/05 14:56
>
> Use an OUTER JOIN
>
> SELECT a.articleid, a.categoryid, a.userid, a.title, c.name, u.firstname,
> count(co.commentid) as nb
> FROM articles a LEFT OUTER JOIN categories c ON
> a.articleid=co.articleid, users u, comments co
> WHERE (c.categoryid = a.categoryid AND u.userid = a.userid) AND
> (co.articleid =
> a.articleid OR co.articleid IS NULL) GROUP BY a.articleid
>
>
> (untested)
>
> Regards
> Stefan
Sorry, query is wrong:
SELECT a.articleid, a.categoryid, a.userid, a.title, c.name, u.firstname,
count(co.commentid) as nb
FROM articles a, categories c, users u LEFT OUTER JOIN comments co ON
co.articleid=a.articleid
WHERE (c.categoryid = a.categoryid AND u.userid = a.userid) AND
(co.articleid =
a.articleid OR co.articleid IS NULL) GROUP BY a.articleid
Navigation:
[Reply to this message]
|