Currently in my Codeigniter site the following works to delete duplicates after sync with google calendar:
$this->db->query("DELETE `e2`.* FROM `ea_appointments` AS `e1`, `ea_appointments` AS `e2`
WHERE `e1`.`id` > `e2`.`id` AND LEFT(`e1`.`id_google_calendar`,26) = LEFT(`e2`.`id_google_calendar`,26)
AND `e2`.`is_unavailable` = 0");
How can I express this in the Active Record format?