Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Query: DELETE and LEFT JOIN

Tags:

mysql

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?

like image 683
Leonardo Avatar asked Feb 18 '11 22:02

Leonardo


1 Answers

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
like image 199
The Scrum Meister Avatar answered Oct 02 '22 18:10

The Scrum Meister