Codoforum related discussions
Update no_posts count

After the import from phpbb3, the counter for the topics table is not correct. This means that I have to edit the value. At the moment no_posts is only updated with a +1 value when a new reply is made. This means that it is not calculated and I need to do this manually.

On my code below the error is You have an error in your SQL syntax;
Can you please let me know what's wrong with my statement?

UPDATE  `codo_topics` SET `no_posts` = (SELECT COUNT(`post_id`) FROM  `codo_posts` WHERE `codo_posts`.`topic_id` = `codo_topics`.`topic_id`)

Thank you so much.

After the import from phpbb3, the counter for the topics table is not correct. This means that I have to edit the value. At the moment no_posts is only updated with a +1 value when a new reply is made. This means that it is not calculated and I need to do this manually. On my code below the error is You have an error in your SQL syntax; Can you please let me know what's wrong with my statement? ```` UPDATE `codo_topics` SET `no_posts` = (SELECT COUNT(`post_id`) FROM `codo_posts` WHERE `codo_posts`.`topic_id` = `codo_topics`.`topic_id`) ```` Thank you so much.

We have already built a class to recount all topics and posts.

But that is automatically called in the import, so there must have been some problem while importing.

Did you get any error ?

As for your query, it looks correct.
I don't have access to the forum code right now (out on vacation), so i cannot debug your query.

We have already built a class to recount all topics and posts. But that is automatically called in the import, so there must have been some problem while importing. Did you get any error ? As for your query, it looks correct. I don't have access to the forum code right now (out on vacation), so i cannot debug your query.
Necessity is the mother of all inventions!

Thanks for your reply. The import did not give any errors.
I ran the query again, must have missed a comma somewehere, because now it is working. smile

Thanks for your reply. The import did not give any errors. I ran the query again, must have missed a comma somewehere, because now it is working. :)
121
2
1
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft