我尝试从表香蕉中删除行,其中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)
但是,它并没有抹去任何东西。
为什么?怎么了?我没有收到错误消息......
谢谢!