我正在升级和优化旧的表结构.
为了正确使用替换,我删除了干扰2列新唯一密钥的旧僵尸条目.
查询:
DELETE from `relProductsPrices` where `ID` in
(SELECT scanA.ID from `relProductsPrices` as scanA
inner join `relProductsPrices` as scanB
where scanA.ID < scanB.ID
and scanA.product = scanB.product
and scanA.priceName = scanB.priceName);
错误:
#1093 - You can't specify target table 'relProductsPrices' for update in FROM clause
我不确定如何正确地将它放入一个mySQL查询中?
我希望这个问题没有重复的条目,我似乎无法找到类似的,适应性的条目.有关于此错误的问题,但我在这里根本没有更新查询,大多数人所说的解决方案(创建一个子选择)已经事先由我完成了.
提前致谢!
最佳答案
试试这个:
原文链接:https://www.f2er.com/mysql/433459.htmlDELETE FROM `relProductsPrices`
WHERE `ID` IN (
SELECT
tmp.ID
FROM (
SELECT
scanA.ID
FROM
`relProductsPrices` as scanA
INNER JOIN `relProductsPrices` as scanB
ON scanA.ID < scanB.ID
AND scanA.product = scanB.product
AND scanA.priceName = scanB.priceName
) as tmp
);