删除查询错误消息:“指定包含您要删除的记录的表”

发布于 2024-11-24 08:12:14 字数 540 浏览 3 评论 0原文

如果记录也在表 D 中,我想删除表“T”中的所有记录,但收到错误消息“指定包含您想要删除的记录的表”。

DELETE T.DISCOUNT_CODE, T.PART_ID, T.SELLING_UM, T.QTY_BREAK_1, T.QTY_BREAK_2, T.QTY_BREAK_3, T.QTY_BREAK_4, T.QTY_BREAK_5, T.QTY_BREAK_6, T.QTY_BREAK_7, T.QTY_BREAK_8, T.QTY_BREAK_9, T.QTY_BREAK_10, T.UNIT_PRICE_10, T.UNIT_PRICE_3, T.UNIT_PRICE_4, T.UNIT_PRICE_5, T.UNIT_PRICE_6, T.UNIT_PRICE_7, T.UNIT_PRICE_8, T.UNIT_PRICE_9, T.UNIT_PRICE_2, T.UNIT_PRICE_1, T.DEFAULT_UNIT_PRICE
 FROM SYSADM_DISCOUNT_PRICE AS T 
 INNER JOIN D ON T.PART_ID = D.PART_ID;

I want to delete all records from table "T" if the records are also in table D, but I am getting the error message "SPECIFY THE TABLE CONTAINING THE RECORDS YOU WANT TO DELETE".

DELETE T.DISCOUNT_CODE, T.PART_ID, T.SELLING_UM, T.QTY_BREAK_1, T.QTY_BREAK_2, T.QTY_BREAK_3, T.QTY_BREAK_4, T.QTY_BREAK_5, T.QTY_BREAK_6, T.QTY_BREAK_7, T.QTY_BREAK_8, T.QTY_BREAK_9, T.QTY_BREAK_10, T.UNIT_PRICE_10, T.UNIT_PRICE_3, T.UNIT_PRICE_4, T.UNIT_PRICE_5, T.UNIT_PRICE_6, T.UNIT_PRICE_7, T.UNIT_PRICE_8, T.UNIT_PRICE_9, T.UNIT_PRICE_2, T.UNIT_PRICE_1, T.DEFAULT_UNIT_PRICE
 FROM SYSADM_DISCOUNT_PRICE AS T 
 INNER JOIN D ON T.PART_ID = D.PART_ID;

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

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

发布评论

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

评论(3

捂风挽笑 2024-12-01 08:12:14

您没有在删除语句中指定列。您也无法加入删除语句。

基本上,您从 table 中删除。因此,将所有条件逻辑放在 where 子句中。

recordid 所在位置(选择……)

You don't specify columns in a delete statement. You also can't join on delete statements.

Basically, you delete from table . So, put all your conditional logic in a where clause.

Where recordid in (select .........)

一世旳自豪 2024-12-01 08:12:14

在 Access 中创建一个新查询,切换到 SQL 视图并将其粘贴到:

DELETE 
FROM SYSADM_DISCOUNT_PRICE AS T
WHERE Exists (SELECT * FROM D WHERE D.PART_ID = T.PART_ID);

如果您“运行”(执行)查询,这应该可以工作。如果要查看受影响的行而不实际执行 DELETE,可以将查询设计器视图切换到数据表视图。这将显示哪些行将被删除,但数据表视图仅显示它们......不删除它们。但是,为了切换到数据表视图,您必须告诉查询设计器要显示哪些字段。您可以通过将第一行更改为 DELETE * 来完成此操作。

另一种方法是将第一行更改为 SELECT * 以便查看受影响的记录,然后在准备删除它们时改回 DELETE。

Create a new query in Access, switch to SQL View and paste this in:

DELETE 
FROM SYSADM_DISCOUNT_PRICE AS T
WHERE Exists (SELECT * FROM D WHERE D.PART_ID = T.PART_ID);

That should work if you "run" (execute) the query. If you want to View the affected rows without actually doing the DELETE, you can switch the query designer view to Datasheet View. That will show you which rows will be subject to deletion, but Datasheet View only displays them ... doesn't delete them. However, in order to switch to datasheet view, you will have to tell the query designer which fields to display. You can do that by changing the first line to DELETE *.

Another approach would be to change the first line to SELECT * in order to view the affected records, then change back to DELETE when you're ready to delete them.

总攻大人 2024-12-01 08:12:14

MS Access 确实允许您加入删除。因此,您可以像这样编写 DELETE 语句,而无需命名列。

DELETE T.*
FROM SYSADM_DISCOUNT_PRICE AS T 
INNER JOIN D ON T.PART_ID = D.PART_ID;

MS Access does let you join on a delete. So you can write you DELETE statement like this without naming the columns.

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