Didn't know if you wanted to change the program or provide a clean up utility, but this will delete all the occasions
|
Code
DELETE FROM ${main::forumprefix}POSTS
WHERE ID IN(
select id from ${main::forumprefix}posts
where not exists (
select * from ${main::forumprefix}topics
where ${main::forumprefix}posts.threadid = ${main::forumprefix}topics.id
)
); |
|
There may or may not be a more efficient query to do the same thing. But it pretty much goes through and deletes all the posts that don't have a thread anymore.
Because the forecasted threads that get deleted with remaining posts is probably gonna be a small number, you'd probably wanna save processing power for the users and just perform this as a utility cleanup maybe once a month. Otherwise, if it happened often, you'd wanna build this into the forum to prevent table bloat, which would increase the seek time.