gpt4 book ai didi

mysql - 查询有什么问题?

转载 作者:行者123 更新时间:2023-11-29 01:31:16 24 4
gpt4 key购买 nike

查询有什么问题?

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 关键字之后添加别名

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'

关于mysql - 查询有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11668822/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com