We have table t_post and table t_post_like.
t_post has a column called like_count, which stores how many likes it got.
Every time a user likes the post, a new row will created in t_post_like, each row contains the post's id in column post_id. the like_count field in t_post will increase by 1 as well.
Now we wish to correct the like_count in t_post with this SQL that I found in this answer:
update p
set p.like_count = l.like_count_by_post
from t_post p inner join
(
select post_id, count(1) like_count_by_post
from t_post_like
group by post_id
) l
on p.id = l.post_id;
But we got error right syntax to use near 'from t_post c inner join..., Is the update set from syntax not supported in MySQL?