Error when deleting from multiple mysql table Unknown table 'table1' in MULTI DELETE

Issue

I ran this query in mysql but it showed an error Unknown table 'table1' in MULTI DELETE. Can anyone guide me on what is wrong please?

DELETE table1, table2,table3, table4
from table1 as t1 
left join table2 as t2
on t1.id = t2.tid 
left join table3 as t3
on t1.id = t3.tid
left jointable4 as t4 
on t1.id = t4.tid 
where t1.id = 77

Solution

That’s because when you use aliases in multiple delete then you must specify the aliases after DELETE statement:

DELETE t1, t2, t3, t4
from table1 as t1 
left join table2 as t2 on t1.id = t2.tid 
left join table3 as t3 on t1.id = t3.tid
left join table4 as t4 on t1.id = t4.tid 
where t1.id = 77

Answered By – Stalinko

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published