MySQL Join Query to Sum a Field in One Table based on Its Corresponding Login ID in another Table -


i have mysql table comment following fields:

loginid submissionid points  

i have mysql table called submission following fields:

loginid submissionid 

for given submissionid, loginid in 2 tables represent different things , therefore nor correspond.

i join sum points loginid. however, not loginid in comment, rather loginid in submission. connection between 2 tables made via submissionid

i can't work. below have far. i'm trying desired sum each loginid pulled another, third table, l.loginid represents.

how can this?

left join (     select c2.submissionid, c2.loginid sum(points) total      comment c2     inner join submission s2     on s2.submissionid = c2.submissionid     group c2.submissionid ) cscs on cscs.loginid = l.loginid 

select s2.loginid, sum(points) total  submission s2 inner join comment c2 on s2.submissionid = c2.submissionid group s2.loginid 

this give points sum each loginid in submission table.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -