Forum Moderators: open

Message Too Old, No Replies

Comments and score are the same

         

FiRe

11:27 am on Dec 14, 2007 (gmt 0)

10+ Year Member



SELECT quotes.*, SUM(votes.score) AS score, COUNT(comments.id) AS comments FROM quotes LEFT JOIN votes ON quotes.id = votes.quoteid LEFT JOIN comments ON quotes.id = comments.quoteid GROUP BY quotes.id HAVING quotes.id = '100009'

For some reason the score is giving me just a minus version of the comments. The votes.score field contains numbers 1 or -1 only. Any help?

Thanks in advance :-)

FiRe

4:29 pm on Dec 14, 2007 (gmt 0)

10+ Year Member



IGNORE ABOVE! This is the query:

SELECT quotes.*, SUM(votes.score) AS score, COUNT(comments.id) AS comments FROM quotes LEFT JOIN votes ON quotes.id = votes.quoteid LEFT JOIN comments ON quotes.id = comments.quoteid GROUP BY quotes.id ORDER BY quotes.id DESC LIMIT 10

It gives comments as 5 and score as -5 instead of comments as 5 and score as +1 :-s