我有以下MySQL查詢:MySQL的刪除與嵌套select查詢
DELETE FROM catalogue
WHERE catalogue_id IN (
SELECT catalogue_id
FROM catalogue
WHERE (
product_id = (SELECT product_id FROM catalogue WHERE catalogue_id = '2290')
AND length_id = (SELECT length_id FROM catalogue WHERE catalogue_id = '2290')
AND gauge_id = (SELECT gauge_id FROM catalogue WHERE catalogue_id = '2290')
)
)
但是,當我嘗試執行我收到以下錯誤信息:
您不能指定目標表'目錄'在FROM子句中更新
有人能告訴我哪裏出錯了嗎?
完美工作zerkms,但是'愚弄'MySQL的原因是什麼? –
如果你有多個「WHERE」列,那麼怎麼辦?即'DELETE FROM catalog WHERE catalogue_id AND catalogue_name IN ...' – ThreaT
@ThreaT:我不確定你在問什麼。多個謂詞可以用ADD來添加,是的。 – zerkms