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 rbaba on 07/24/05 15:22

THX Stefan,
It works !

"Stefan Rybacki" <stefan.rybacki@gmx.net> a ιcrit dans le message de news:
3khdufFugjj4U3@individual.net...
>>
>> 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация