我最近在搞 mysql,遇到了问题。我尽力将问题描述清楚。
我有四个表 comment, article, user, comment_article
user 表与 comment 表是一对多
article 与 comment 表是多对多,所以 comment_article 即为两者关系映射。
article,comment,user 表都是用爬虫数据填充完毕。
现在我有这样一个需求:
我想填充 comment_article 表数据,但是 article 数据比 comment 数据多。
我需要保证每篇文章下不少与五条的 comment 记录。
我使用了 insert into comment_article (articleid) select id from article;连续插入了十次
然后 update comment_article set comment=(select id from comment order by rand() limit 1);
然后就出了一个 lock .... transaction 的错误 time out
我现在脑子一团浆糊,没有思路,你们能给我些许思路了?