DELETE FROM programSchedule
LEFT JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
我收到此错误:
#1064 - 您的SQL语法出错;检查手册 对应于您的MySQL服务器 用于正确语法的版本 靠近'LEFT JOIN program ON programSchedule.pid = program.id'at 第1行
为什么?
答案 0 :(得分:8)
您需要指定要删除的表格。
DELETE programSchedule.*
FROM programSchedule LEFT JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
注意:由于您要按INNER JOIN
program.channel_id
DELETE programSchedule.*
FROM programSchedule INNER JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
答案 1 :(得分:2)
由于涉及两个表,您需要说明要从哪个表中删除。因此,为了删除programSchedule
表中的行,您可以执行以下操作:
DELETE programSchedule.*
FROM programSchedule
LEFT JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10