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 8393983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:56:51+00:00 2026-06-09T19:56:51+00:00

Alright, have to be missing something here. My SQL works fine: SELECT t1.id, t1.material,

  • 0

Alright, have to be missing something here.

My SQL works fine:

SELECT t1.id, t1.material, t2.id, t2.material, t3.id, t3.material, t4.id, t4.material
FROM ml_levels t1 

LEFT JOIN ml_levels t2 
ON t1.parentID = t2.id

LEFT JOIN ml_levels t3
ON t2.parentID = t3.id

LEFT JOIN ml_levels t4
ON t3.parentID = t4.id

WHERE t1.id = 286

This returns

id   |  material  | id  |  material         |  id  |  material            | id |  material
-------------------------------------------------------------------------------------------
286  |  4Layer    | 209 |  Protective Film  |  60  |  Specialty Products  | 1  |  Protect 

However, my ActiveRecord is only returning t4.id and t4.material:

    $this->db->select('t1.id, t1.material, t2.id, t2.material, t3.id, t3.material, t4.id, t4.material');
    $this->db->from('ml_levels AS t1')->where('t1.id',286);
    $this->db->join('ml_levels AS t2','t1.parentID = t2.id','left');
    $this->db->join('ml_levels AS t3','t2.parentID = t3.id','left');
    $this->db->join('ml_levels AS t4','t3.parentID = t4.id','left');

    return $this->db->get()->row();

this returns:

id   |  material  |
-------------------
1    |  Protect   |

$this->db->last_query() returns:

SELECT `t1`.`id`, `t1`.`material`, `t2`.`id`, `t2`.`material`, `t3`.`id`, `t3`.`material`, `t4`.`id`, `t4`.`material` 
FROM (`ml_levels` AS t1) 
LEFT JOIN `ml_levels` AS t2 ON `t1`.`parentID` = `t2`.`id` 
LEFT JOIN `ml_levels` AS t3 ON `t2`.`parentID` = `t3`.`id` 
LEFT JOIN `ml_levels` AS t4 ON `t3`.`parentID` = `t4`.`id` 
WHERE `t1`.`id` = 286 

And if I run this SQL on the database, it returns exactly what the original query returned.

  • 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-06-09T19:56:52+00:00Added an answer on June 9, 2026 at 7:56 pm

    Codeigniter return only field name without table label so that you found only two fields because there are only id and material. Change line:

     $this->db->select('t1.id, t1.material, t2.id, t2.material, t3.id, t3.material, t4.id, t4.material'); 
    

    with:

     $this->db->select('t1.id AS t1id, t1.material AS t1material, t2.id AS t2id, t2.material AS t2material, t3.id AS t3id, t3.material AS t3material, t4.id AS t4id, t4.material AS t4material'); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright so I have a php script which gets results from a DB, and
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(
Alright I have a table where I need to get the relevant date from
Alright so i have been working on this Dynamic load of a spinner from
Alright basically i have the code at the bottom and it works perfectly if
Alright, I have a strange one here. We currently have a tools application that
Alright I have a gigantic list of files I would like to copy from
Alright I have an xml document that looks something like this: <xml> <list> <partner>
Alright have been working to switch to jQuery 1.7's new and improved .on() function
Alright i have a for loop in php and it generates a group of

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.