Есть задача удалить дубликаты по полю code.
Пишу такой запрос:
DELETE FROM `salesrule_coupon` as t1 WHERE t1.code in (SELECT t2.code FROM `salesrule_coupon` as t2 GROUP BY t2.`code` HAVING count(*) > 1)
Ошибка:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as t1 WHERE t1.code in (SELECT t3.code FROM `salesrule_coupon` as t3 GROUP BY t3' at line 1
В чем может быть проблема?
UPD: Структура таблицы:
i.imgur.com/SpCwxbS.png