update user a set a.posts=
(select
b.counts
from
(select authorid,count(*) counts from post group by authorid) b
where a.uid=b.authorid)
INSERT INTO user(uid,posts) (SELECT authorid,COUNT(authorid) FROM POST GROUP BY authorid)
解决问题!
update user set posts = (select count(1) from post where authorid = user.uid)