You might try this, using CodeIgniter’s Active Record class:

$this->db->join("table2", "table1.thing_id =")
  ->where("table2.otherthing_id", $id)


This doesn’t work, as CodeIgniter ignores joins when doing Active Record deletes.

Instead, you’ll have to write out the SQL ‘manually’ – something like this:

$sql = "DELETE t1 FROM table1 t1
  JOIN table2 t2 ON t1.thing_id =
  WHERE t2.otherthing_id = ?";
$this->db->query($sql, array($id));

We love solving problems. If you want to find out more about what we do, get in touch with us here.