将多行从一个表传输到另一个表

发布于 2024-10-05 19:02:01 字数 143 浏览 0 评论 0原文

我创建了一个名为 Rate 的新表,用于对帖子表中的帖子进行评级。 Posts 表已有数据,但 Rate 为空。当我创建新帖子时,其 ID 会添加到费率中,但有许多未添加的帖子是在费率表之前发布的。

我可以使用哪种查询将多行从帖子(仅 ID)传输到费率表?

I created a new table named Rate for rating posts from my Posts table. The Posts table already has data but Rate is empty. When I create a new post, its ID is added to Rate but there are many posts not added that were published before the Rate table.

What sort of query can I use to transfer multiple rows from Posts (just the ids) to the Rate table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲墙角沉默 2024-10-12 19:02:01

使用 MySQL INSERT ... SELECT 用于将数据从一个表插入到另一个表。例如:

 INSERT INTO Rate (ID, col1, col2) SELECT ID, somecol1, somecol2 FROM Posts WHERE ....

Use the MySQL INSERT ... SELECT for inserting data from one table to another. e.g.:

 INSERT INTO Rate (ID, col1, col2) SELECT ID, somecol1, somecol2 FROM Posts WHERE ....
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文