Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7637759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:01:01+00:00 2026-05-31T08:01:01+00:00

I have a table lists containing list information like title and id (auto_increment) and

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T08:01:02+00:00Added an answer on May 31, 2026 at 8:01 am

    Try using this:

    $this->db->select('lists.*, x.cnt from lists, (select count(*) as cnt from list_items) as x', NULL, FALSE);
    $result = $this->db->get('Table_Name');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing a list of folders, each folder has an ID
Say I have a table with 5000 records, and another table containing a list
I have a table with many rows and each row has select lists. Something
I have an R list containing a series of tables. Each table in the
I currently have a code table containing a list of types (Type_ID, Description), but
I have 3 tables. An Applications (relevant field is AppID) table containing information about
Say I have at database table containing information about a news article in each
I have two tables containing product information, and product variations. I’m trying to list
I have a table containing a list of individual prices for a variety of
I have a table containing a list of events with a start date and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.