zujixie分散帖子

–将指定人的帖子时间分散,authorid=2是 uid=2的用户 create table zjx_forum_thread_tmp (td_id int, dateline int); insert into zjx_forum_thread_tmp select tid,((select max(dateline) from zjx_forum_thread)+ROUND(RAND() 1000000000)%(UNIX_TIMESTAMP()-(select max(t2.dateline) from zjx_forum_thread t2))) from zjx_forum_thread WHERE authorid=57; update zjx_forum_thread set dateline=(select dateline from zjx_forum_thread_tmp t where t.td_id= tid) where authorid=57; drop table zjx_forum_thread_tmp; update zjx_forum_thread set lastpost=dateline WHERE authorid=57; //将指定人的帖子的作者分散,authorid=2是 uid=2的用户 update zjx_forum_thread set authorid = ROUND(RAND() 10000)%(select max(uid) from zjx_common_member) where authorid=57; //下面这句是将不在用户表中的authorid,重新生成。要反复执行多次,直到反更新的条目为0, update zjx_forum_thread set authorid = ROUND(RAND() *10000)%(select max(uid) from zjx_common_member) WHERE authorid not in (select uid from zjx_common_member); //根据authorid重新生成author和lastposter update zjx_forum_thread set author=(select username from zjx_common_member where uid=authorid), lastposter=(select username from zjx_common_member where uid=authorid); //更新forum_post,使author、authorid、dateline与forum_thread一致 update zjx_forum_post p set author=(select author from zjx_forum_thread t where t.tid=p.tid), authorid=(select authorid from zjx_forum_thread t where t.tid=p.tid), dateline=(select dateline from zjx_forum_thread t where t.tid=p.tid); ===================================================== yahewan