I have a table lists containing list information like title and id (auto_increment) and another table storing items. The list_items table has a parent field which is the id of the list it belongs to.
I’m trying to pull list information with an additional column for keeping track of number of items for that list stored under list_items.
This query works:
select lists.*, x.cnt
from lists, (select count(*) as cnt from list_items) as x
How to write the same using CodeIgniter Active Record?
Try using this: