• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mysql query - one row details, child rows

#1
[eluser]iamzozo[/eluser]
Hi!

I've created a query
Code:
$this->db->select('a.id, a.title, b.child_title');
$this->db->from('a');
$this->db->where('a.id', $id);
$this->db->join('b','a.id = b.parent');
$this->db->get();

It's working fine, but i would like the result show up something like this:
[id] => 1,
[title] => Lorem ipsum,
[child_titles] => Array()....

Now it gives in each object the a.title (as join work).

- I did it with two query, but is it possible to create this with one query?
- Has the two query (much) slower performance (one row query, one list)? - "a" table has got aprox 30K rows, "b" has got aprox. 600K.

Thanks!


Messages In This Thread
Mysql query - one row details, child rows - by El Forum - 06-20-2012, 05:59 AM
Mysql query - one row details, child rows - by El Forum - 06-20-2012, 06:40 AM
Mysql query - one row details, child rows - by El Forum - 06-20-2012, 06:56 AM
Mysql query - one row details, child rows - by El Forum - 06-20-2012, 07:22 AM
Mysql query - one row details, child rows - by El Forum - 06-20-2012, 07:47 AM
Mysql query - one row details, child rows - by El Forum - 06-20-2012, 07:50 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.