Hi, I took over a database with two tables, lets name them entries
and comments
.
The entries
table contains a column named comment_count which holds the amount of rows with entry_id in comments
corresponding to that row in entries
.
Lately this connection has become terribly out of sync due to version switching of the codebase. I need help to build a query to run in phpmyadmin to sync these numbers again. The amount of rows in entries
is around 8000 and the rows in comments
is around 80000 so it shouldn't be any problems to run the sync-query.
Structure:
entries
countains:id
|comment_count
| etccomments
containsid
|blogentry_id
| etc
The only way I can think of is to loop each entry in the entries
table with php and update individually but that seems extremly fragile compared to a pure SQL solution.
I'd appriciate for any help!