Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- update table with select and group by statement
- -- Ohs my poor SQL.
- -- contacts:beginman.cn
- update group_info as g
- left join (
- select gi.group_id, count(gm.id) as nums from group_info gi
- inner join group_members gm on gm.group_id = gi.group_id
- group by gm.group_id
- )
- as m on g.group_id = m.group_id
- set g.member_count = m.nums;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement