I'm trying to apply a DELETE
to more than one table, tables have a column (not with the same name) with the same attributes. I want to delete via ID. But I have the table usuario
with column id and areausuario
with column idUsuario
, are the same attributes ( id = 1
, IdUsuario = 1
).
I was trying with this code.
DELETE us.*
FROM usuarios us
INNER JOIN disponibilidade ds ON (us.id = ds.IdUsuarios)
INNER JOIN areausuarios au ON (ds.IdUsuarios = au.IdUsuarios)
INNER JOIN gestor g ON (au.IdUsuarios = g.id)
WHERE g.id = 7;
But this code is deleting only from a table.
I've tried a few more but it applies the error 1451 , where I can not delete the usuario
, without first removing it from the areausuarios
table. >