How to express a DELETE WHERE NOT IN (subquery) using CodeIgniter's query builder
How can I convert the following raw SQL into CodeIgniter's query builder methods?
$this->db->query('
DELETE FROM default_model
WHERE cat_id NOT IN (
SELECT id
FROM default_category
)
');
I tried with:
$query = $this->db
->select('id')
->get('category')
->result();
$this->db
->where_not_in('cat_id', $query)
->delete('model');
I tried a lot of things, but could not do it. How can I resolve this?