I want to run this query in order to update the comment_count in my WordPress wp_posts table with the comments which are actually in the wp_comments table. It seems that there went something wrong in previous hosting environments:
UPDATE wp_posts SET wp_posts.comment_count = (SELECT COUNT(*) FROM wp_comments WHERE wp_comments.comment_post_ID = wp_posts.ID AND wp_comments.comment_approved = '1' );
However I get this error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
The phpmyadmin shows the “(” before SELECT. Locally it went fine. Does anybody know what is wrong here?