我设法编写了一个查询,该查询可以撤回在单独的表中没有项目的订单。我现在想根据返回的记录集更新 xxx_orders。可以在一个查询中完成吗?
SELECT Orders.OrderNumber,
Orders.CustomerNumber,
AffiliateCode
FROM xxx_orders AS Orders
LEFT OUTER JOIN xxx_items AS Items
ON Orders.OrderNumber = Items.OrderNumber
WHERE DATEDIFF(NOW(), OrderDate) >= 14
AND Orders.Product = 'HOUSEHOLD'
AND STATUS = 'BOOKING'
AND Completed = 1
AND Items.Id IS NULL
ORDER BY OrderDate DESC