delete record from an sql table

0

Good people I want to erase a record from a table but for this I need to go get information from other tables and because of this I am not able to delete.

I basically needed an SQL command that would receive the patient id from the patient table, via which id_agregado belongs to that patient in the utenteagregado table and deletes everything belonging to that id_agregado in the agregado table. I already tried but all the commands give me syntax error.

Thank you

    
asked by anonymous 06.05.2015 / 20:39

1 answer

2

Looks for help

DELETE FROM AGREGADO
WHERE AGREDADO.ID_AGREGADO IN (
  SELECT utenteagregado.ID_AGREGADO FROM utenteagregado
  WHERE utenteagregado.ID_PACIENTE = ?
)
    
06.05.2015 / 20:48