Mysql 什么';这个问题怎么了?

Mysql 什么';这个问题怎么了?,mysql,sql,sql-delete,cascade,cascading-deletes,Mysql,Sql,Sql Delete,Cascade,Cascading Deletes,这个问题怎么了 delete from categories c left join categories_products cp on cp.category_id = c.id left join products p on p.id = cp.product_id left join images i on i.object_id = cp.product_id where c.id = 3 and i.site_section = 'products' MySQL返回错误。我试图通过H

这个问题怎么了

delete from categories c
left join categories_products cp on cp.category_id = c.id
left join products p on p.id = cp.product_id
left join images i on i.object_id = cp.product_id
where c.id = 3 and i.site_section = 'products'
MySQL返回错误。我试图通过HeidiSQL执行这个查询。错误未知

另一个问题也会对我有所帮助:若并没有索引,那个么如何进行行的级联删除

delete c from categories c
left join categories_products cp on cp.category_id = c.id
left join products p on p.id = cp.product_id
left join images i on i.object_id = cp.product_id
where c.id = 3 and i.site_section = 'products'

加入时,必须指定要从哪个表中删除。这就是为什么
delete c from…

您应该在
delete
关键字之后添加别名

DELETE c FROM categories c
          LEFT JOIN categories_products cp 
                    on cp.category_id = c.id
          LEFT JOIN products p 
                    on p.id = cp.product_id
          LEFT JOIN images i on i.object_id = cp.product_id
WHERE c.id = 3 and i.site_section = 'products'

谢谢但我正在尝试删除“c”、“cp”和“I”表中的行,并且只删除“c”表中的行。此链接可能会帮助您:)谢谢,想法很清楚。删除关键字后有很多别名:)