Short
My tables structure looks like that
And here is Sql statements
$stmt = $this->db->prepare("DELETE FROM chapters WHERE (subject_id=? AND id = ?)") or die($this->db->error());
$stmt->bind_param("ii", $subject_id, $node);
$stmt->execute();
$stmt = $this->db->prepare("DELETE FROM sections WHERE (subject_id=? AND chapter_id=? )") or die($this->db->error());
$stmt->bind_param("ii", $subject_id, $node);
$stmt->execute();
$stmt = $this->db->prepare("DELETE FROM paragraphs WHERE (subject_id=? AND chapter_id=?)") or die($this->db->error());
$stmt->bind_param("ii", $subject_id, $node);
$stmt->execute();
So what I want to do is, to merge
this 3 statements into one and optimize server load.
Detailed
For ex., if I want to delete row with id=1 from chapters
table, then also delete from 2 more tables: sections
, paragraphs
by 2 parameters: $node
and $subject_id
(Of course, If there is rows with those parameters. I mean there must be join to prevent any error).
Question is..
Is that possible? I can't figure out, how sql statement must look like. Any suggestions?