I do not have a query handy to do that, but I know I have seen it posted before (at least for the post and thread table). If I recall, the userid for the post/threadstarter will be 0, but the username will still have the users username there. So, your query needs to set the userid in the post and thread table (possibly attachment/filedata table also, which could get messy) to be the new userid WHERE username=username. So, try a search to find it.