删除查询错误消息:“指定包含您要删除的记录的表”
如果记录也在表 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有在删除语句中指定列。您也无法加入删除语句。
基本上,您从 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 .........)
在 Access 中创建一个新查询,切换到 SQL 视图并将其粘贴到:
如果您“运行”(执行)查询,这应该可以工作。如果要查看受影响的行而不实际执行 DELETE,可以将查询设计器视图切换到数据表视图。这将显示哪些行将被删除,但数据表视图仅显示它们......不删除它们。但是,为了切换到数据表视图,您必须告诉查询设计器要显示哪些字段。您可以通过将第一行更改为
DELETE *
来完成此操作。另一种方法是将第一行更改为 SELECT * 以便查看受影响的记录,然后在准备删除它们时改回 DELETE。
Create a new query in Access, switch to SQL View and paste this in:
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.MS Access 确实允许您加入删除。因此,您可以像这样编写 DELETE 语句,而无需命名列。
MS Access does let you join on a delete. So you can write you DELETE statement like this without naming the columns.