I have a table with 4 tables in it. ID, USERID, THREADID, VOTE Now I have a bunch of duplicate THREADID's.. and I want to merge them all so I can add all the VOTE's. here is an example: ID, USERID, THREADID, VOTE 1 5 24 1 2 6 24 1 3 6 24 3 4 3 10 1 I want to merge the 24's, so I can total the votes eg. 5 votes in that thread. I assume I have to do a join??
SELECT THREADID, SUM(VOTE) FROM VOTETABLE GROUP BY THREADID; That should do the trick keep in mind that this query can become rather expensive if the table has a large number of records.