mysql – 错误查询:DELETE和LEFT JOIN

前端之家收集整理的这篇文章主要介绍了mysql – 错误查询:DELETE和LEFT JOIN前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

DELETE FROM programSchedule 
LEFT JOIN program ON programSchedule.pid = program.id 
WHERE program.channel_id = 10

我收到此错误

#1064 – You have an error in your sql Syntax; check the manual that
corresponds to your MysqL server
version for the right Syntax to use
near ‘LEFT JOIN program ON
programSchedule.pid = program.id’ at
line 1

为什么?

最佳答案
您需要指定要从中删除的表.

DELETE programSchedule.*
FROM programSchedule LEFT JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10

注意:由于您要通过program.channel_id进行过滤,因此将连接更改为INNER JOIN

DELETE programSchedule.*
FROM programSchedule INNER JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
原文链接:https://www.f2er.com/mysql/433364.html

猜你在找的MySQL相关文章