Page 1 of 1

Merging results

Posted: Fri Jul 21, 2006 9:42 am
by mikitoq
Hi,

I have three tables as follows..
comments
topics
scores

each have a user_id and a user_points field. I want to take the values for user_points from comments and topics for all users, add these together and populate the scores table.

e.g user_id of 1 has 3 topics + 4 comments so my query should now populate scores as follows
user_id = 1
user_points = 7

etc..

Can this be done in a single query and if so how do I go about doing it?

Thanks in advance!!

M

Posted: Fri Jul 21, 2006 10:46 am
by Chris Corbyn
Sounds like you could do it with an "insert..select" but I'd probably need to see your table structures as reported by MySQL first.