|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Sebastian Mendel (lists
sebastianmendel.de)
Date: Wed Mar 05 2008 - 02:29:03 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Patrick Aljord schrieb:
> Hey all,
> I have comments(id,content) and votes(comment_id,vote). vote is a tinyint.
>
> I would like to select total votes for each comment, I tried:
>
> "select content, sum(v.votes) from comments c left join votes v on
> c.id=v.comment_id"
>
> but it only returns first result obviously, any idea how I could do this?
did you tried in your mysql console?
please add the output here
and add GROUP BY - this is required by SQL standard
SELECT
comments.content,
SUM(votes.votes)
FROM
comments
LEFT JOIN
votes
ON
comments.id = votes.comment_id
GROUP BY
comments.id
--
Sebastian Mendel
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]