You are here: Re: Please Help: 4 tables 1 query « PHP SQL « IT news, forums, messages
Re: Please Help: 4 tables 1 query

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация