我目前的问题如下。 下面的选择脚本完美地工作。删除mysql查询
SELECT *
FROM orderheader, orderbody, orderbodylocation
WHERE orderheader.DateCreated > '2011-02-01 00:00:00'
AND orderheader.OrderID = orderbody.OrderID
AND orderbody.OrderBodyID = orderbodylocation.OrderBodyID
AND orderbody.OrderID = orderbodylocation.OrderID
AND orderheader.Status <= 1
但低于删除查询这是where子句的复制失败围绕dateCreated会子句。
DELETE
FROM orderheader, orderbody, orderbodylocation
WHERE orderheader.DateCreated > '2011-02-01 00:00:00'
AND orderheader.OrderID = orderbody.OrderID
AND orderbody.OrderBodyID = orderbodylocation.OrderBodyID
AND orderbody.OrderID = orderbodylocation.OrderID
AND orderheader.Status <= 1
orderheader表内的DateCreated字段是DATETIME类型。
我试图删除每个订单更新,然后1-2-2011(d-m-y)以及订购人关联的表数据在orderbody和orderbodylocation表中。
我已经用完了想法,而且我还没有太多有关MySQL DateTime数据类型字段的经验。 如果任何人都可以看到我的错误,将不胜感激,如果你可以让我知道我做错了什么。
什么是错误? – 2011-02-08 02:06:46
[offtop]当外键约束与删除级联是一个很好的工具[/ offtop] – zerkms 2011-02-08 02:11:18