Ver originalCREATE TEMPORARY TABLE msj_tempSELECT U.ID_user FROM usuarios U LEFT JOIN mensajes M ON U.ID_user = M.ID_userWHERE M.ID_user IS NULL; DELETE FROM mensajes WHERE ID_user IN (SELECT U.ID_user FROM msj_temp);