Hello,
I have been unable to get a better result than the multiplication of 2
tables where I want the addition.
I explain :
3 tables, one for genre, one for html and one for shockwave
html and shockwave have foreign key genreID
I want to count how many html and shockwave entries have the same genreID,
so I can have as a result :
genreID ! nbgenre
1 ! 6
2 ! 2
3 ! 8
where for exemple genreID 1 has 4 html and 2 shockwave entries.
Here's one query I've tested and that doesn't return the addition of html
and shockwave entries, but their multiplication !!!?? (in the exemple I
obtain for genbreID 1 => 4 * 2 = 8 instead of 6)
$query = "SELECT COUNT(*) as nbgenre, g.intitule, g.genreID
FROM genre g, html h, shockwave s
WHERE g.genreID = s.genreID
AND g.genreID = h.genreID
GROUP BY g.intitule, g.genreID
ORDER BY nbgenre DESC, g.intitule
I've tried using LEFT JOIN from exemples on the web, but I don't have enough
experience in SQL to use them correctly in my own queries, and I am not sure
it would solve the problem or if it's just another way of obtaining the same
(wrong) result.
Cheers,
Damien
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php