delete record from an sql table

Asked

Viewed 125 times

0

Good people I want to delete a record from a table but for that I need to get information from other tables and because of that I am not able to delete. inserir a descrição da imagem aqui

I basically needed an SQL command that received the patient id from the patient table, via which id_agregado belong to this patient in the table utenteagregado and erased everything belonging to that id_agregado on the table agregado. I’ve tried but all commands give me syntax error.

Thank you

  • your question is very wide, please add your SQL queries that cause errors, if possible create the structure and data at http://sqlfiddle.com/ and add the link here

  • It’s settled, thank you.

1 answer

2


Look if it helps

DELETE FROM AGREGADO
WHERE AGREDADO.ID_AGREGADO IN (
  SELECT utenteagregado.ID_AGREGADO FROM utenteagregado
  WHERE utenteagregado.ID_PACIENTE = ?
)
  • Thank you very much, that’s exactly what I wanted

Browser other questions tagged

You are not signed in. Login or sign up in order to post.