1

我正在尝试对本地 Access 表运行此删除查询,但我收到错误消息

无法从指定表中删除

请为我提供正确的 SQL 以进行复制和粘贴。

非常感谢你,纳撒尼尔

DELETE RO.*, RO.STATUS, CO.ID, CO.PRINTED_DATE
FROM tmpReleasedOrders AS RO 
LEFT JOIN SYSADM_CUSTOMER_ORDER AS CO ON RO.orderID = CO.ID
WHERE (((RO.STATUS)="C" Or (RO.STATUS)="X")) OR (((CO.ID) Is Null)) OR (((CO.PRINTED_DATE) Is Null));
4

1 回答 1

1

此查询依赖于 SYSADM_CUSTOMER_ORDER 在 ID 上具有唯一索引。

DELETE ro.*
FROM tmpReleasedOrders AS ro
LEFT JOIN SYSADM_CUSTOMER_ORDER AS CO 
ON RO.orderID = CO.ID
WHERE RO.STATUS="C" Or RO.STATUS="X" OR CO.ID Is Null OR CO.PRINTED_DATE Is Null

如果您在 SYSADM_CUSTOMER_ORDER 上没有索引,则可以在这些行中使用一些内容:

DELETE tmpreleasedorders.*
FROM tmpreleasedorders
WHERE  status IN ( "c", "x" )
OR orderid IN (
   SELECT orderid
   FROM   tmpreleasedorders AS ro
   LEFT JOIN sysadm_customer_order AS CO
   ON RO.orderid = CO.id
   WHERE  CO.id IS NULL
   OR CO.printed_date IS NULL) 
于 2012-10-29T00:05:17.113 回答