DELETE行FROM表WHERE字段值是另一个复杂查询的结果

时间:2017-10-23 21:01:12

标签: mysql sql delete-row

我尝试从表香蕉中删除行,其中id必须等于此查询的结果:

    SELECT DISTINCT (ub.userId) as id
FROM new_users_bonus ub 
JOIN new_users_used_bonus uub ON ub.userBonusId = uub.userBonusId 
JOIN new_bonus_details bd ON bd.bonusId = ub.bonusId
JOIN new_bonus b ON b.bonusId = bd.bonusId
WHERE b.prefix LIKE 'AEJ'
AND (ub.expirationDate <= '2017-10-23'
OR ub.bonusValue - (SELECT SUM(usedValue) as totalUsedValue FROM new_users_used_bonus uub2 where ub.userBonusId = uub2.userBonusId) <= 0)
GROUP BY ub.bonusId, ub.redeemedDate
ORDER BY ub.expirationDate ASC

我写过:

DELETE FROM bananas WHERE id = ANY (complex query written before)

DELETE FROM bananas WHERE id IN (complex query written before)

但是,它并没有抹去任何东西。 为什么?怎么了?我没有收到错误消息......
谢谢!

0 个答案:

没有答案