MySQL SUM(GROUP BY) -


i trying add columns id same. i'm new mysql appears group by need.

here attempt gives me syntax error

|siteid|staffid|holiday|total

update sitestaff set total = sum(h.holiday)  group h.staffid 

i suspect have holiday table. if so, want query uses join update, , looks this:

update sitestaff ss left join        (select h.staffid, sum(h.holiday) total         holidays h         group h.staffid        ) h        on ss.staffid = h.staffid     set ss.total = coalesce(t.total, 0); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -