将信息从一个表移动到另一个表,然后从其源中删除该数据

发布于 2024-11-28 16:22:31 字数 388 浏览 1 评论 0原文

我正在制作一个名册创建工具,该工具的一部分是将毕业的学生从名册池中删除,并将其放入另一个名为 CompletedArchive 的表中。将它们复制到另一个表后,我希望将它们从 RosterPool 表中删除。

INSERT INTO CompletedArchive ( Rate, FullName, Last4, Graduated )
SELECT RosterPool.Rate, RosterPool.FullName, RosterPool.Last4, RosterPool.Graduated
FROM RosterPool
WHERE ((RosterPool.Graduated)="Yes");

我无法找到在哪里添加 DELETE 语句并且不会出现错误。任何帮助表示赞赏!

I'm making a roster creation tool and one part of the tool is to remove the graduated students from the roster pool and put them into another table called CompletedArchive. After they are copied to the other table I want them to be deleted from the RosterPool table.

INSERT INTO CompletedArchive ( Rate, FullName, Last4, Graduated )
SELECT RosterPool.Rate, RosterPool.FullName, RosterPool.Last4, RosterPool.Graduated
FROM RosterPool
WHERE ((RosterPool.Graduated)="Yes");

I cannot find out where to add the DELETE statement and not get an error. Any help is appreciated!

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

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

发布评论

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

评论(1

只想待在家 2024-12-05 16:22:31

您必须在此处运行两个不同的命令:

INSERT INTO CompletedArchive ( Rate, FullName, Last4, Graduated )
SELECT RosterPool.Rate, RosterPool.FullName, RosterPool.Last4, RosterPool.Graduated
FROM RosterPool
WHERE ((RosterPool.Graduated)="Yes");

然后

DELETE FROM RosterPool
WHERE ((RosterPool.Graduated)="Yes");

此外,请确保在同一事务中运行这两个命令。这样,如果出现任何问题,您将有机会回滚。

You have to run two different commands here:

INSERT INTO CompletedArchive ( Rate, FullName, Last4, Graduated )
SELECT RosterPool.Rate, RosterPool.FullName, RosterPool.Last4, RosterPool.Graduated
FROM RosterPool
WHERE ((RosterPool.Graduated)="Yes");

and then

DELETE FROM RosterPool
WHERE ((RosterPool.Graduated)="Yes");

Also, make sure you run the two commands within the same transaction. That way you will have the chance to rollback if anything goes wrong.

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