Categories
Dev

Mysql Delete with null left join

If you do:

Select * from table left join other_table on id=ext_id where ext_id is null

it works great. But if you want to convert that select to a delete you need to include ‘table.*‘:

Delete table.* left join other_table on id=ext_id where ext_id is null

It kind of makes sense, but MySql could be smart and get that we only want to delete from where there actually exists content.

By Hugo Gameiro

I run Masto.host, a fully managed hosting solution for Mastodon instances and Nuvens.pt, a Portuguese hosting service for websites.
mastodon | email