我想删除tbl_Billing中的记录,我想在执行此功能时使用LIMIT。请建议是否可以使用INNER JOIN或LEFT JOIN。查询在
下面DELETE
FROM tbl_Billing
WHERE `aCreated` > '2011-01-09'
AND `aStatus` ='2'
AND `aUserUnique`
IN (
SELECT aUserUnique
FROM tbl_Users AS user
WHERE user.`aBillingRenew` < date_sub( now( ) , INTERVAL 60 DAY )
AND user.aActive =1
)
答案 0 :(得分:1)
我得到了答案。我们必须使用EXISTS
而不是IN
运算符:
DELETE
FROM tbl_Billing
WHERE `aCreated` > '2011-01-09'
AND `aStatus` ='2'
AND EXISTS
(
SELECT aUserUnique
FROM tbl_Users AS users
WHERE users.`aBillingRenew` < date_sub( now( ) , INTERVAL 60 DAY )
AND users.aActive ='1'
)
limit 10