I have 3 tables in my MySQL
database.
Clientes (existe el DNI)
Clientes_compra (puede existir el DNI o quizás no).
Clientes_alquiler (puede existir el DNI o quizás no).
My intention is to ask for a Java program the textfield_DNI and if it matches a DNI
of the table clientes
that erases it from this table and the other two, if it exists.
DELETE FROM clientes WHERE dni="13225217P";
DELETE FROM clientes_compra WHERE dni="13225217P";
DELETE FROM clientes_alquiler WHERE dni="13225217P";
I think there is a cascade deletion ( CASCADE ON ), how would it be in a single query and not have to use 3?
Execution of error:
Cannot delete or update a parent row: a foreign key constraint fails ('osmarentcars'.'clientes_alquiler', CONSTRAINT 'FK_CLIENTES_ALQUILER1' FOREIGN KEY ('DNI') REFERENCES 'clientes' ('DNI'))