delete from tx_table
where buyer_id in(select t.buyer_id
from tx_table t
left join user_table u
on t.buyer_id=u.user_id
where u.user_id is null)
上述查询出现错误。错误是
sql error 1093:You can't specify target table 'tx_table' for update in FROM clause
请帮帮我
最佳答案
试试这个:
DELETE FROM tx_table
WHERE buyer_id IN (
SELECT buyer_id FROM (
SELECT DISTINCT t.buyer_id AS buyer_id FROM tx_table
LEFT JOIN user_table u on t.buyer_id=u.user_id where u.user_id is null
) AS c
)
关于mysql - mysql删除查询出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29071812/