我想根据不同表中的条件删除一个表中的记录,但是我收到错误消息:“指定包含要删除的记录的表”(我只想删除表中的所有记录) “RO”,表“CO”仅用于标准目的)。请提供适当的SQL来复制和粘贴(我不知道SQL。我使用查询构建器)。
DELETE CO.ID, CO.PRINTED_DATE, RO.STATUS, RO.orderID, RO.CREATE_DATE, RO.NAME, RO.cust_ID, RO.lines, RO.PICKER, RO.COMMENTS, RO.sls_rep, RO.weight, RO.PO_number, RO.Tracking_Number, RO.ship_via, RO.nmbrOfBoxes
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));
答案 0 :(得分:1)
以下是具有来自另一个表的条件的删除查询的语法:
DELETE tmpReleasedOrders.*
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)