Error Query: DELETE and LEFT JOIN
DELETE FROM programSchedule
LEFT JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
I get this error:
#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
Why?
You need to specify what table to delete from.
DELETE programSchedule.*
FROM programSchedule LEFT JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
Note: Change the join to a INNER JOIN
since you are filtering by program.channel_id
DELETE programSchedule.*
FROM programSchedule INNER JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
Because two tables are involved, you need to say which table you'd like to delete from. So in order to delete the rows in the programSchedule
table, you can do this:
DELETE programSchedule.*
FROM programSchedule
LEFT JOIN program ON programSchedule.pid = program.id
WHERE program.channel_id = 10
精彩评论