CodeIgniter Forums
Query Problem (Multiple Tables) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Query Problem (Multiple Tables) (/thread-10124.html)



Query Problem (Multiple Tables) - El Forum - 07-19-2008

[eluser]ywftdg[/eluser]
Hey guys, stuck again on something. Im learning, newbie styles...

I have this setup:

Code:
$this->db->where('field_id_8', $this->uri->segment(1));
$data['queryB'] = $this->db->get('exp_weblog_data');
        
$sql = "SELECT * FROM exp_weblog_data, exp_weblog_titles WHERE exp_weblog_data.entry_id = exp_weblog_titles.entry_id";
$data['queryA'] = $this->db->query($sql);

My problem is, in the blank area, I am assuming I need to do some sort of join, in order for my second query to only be pulling results, based on the results of the first query. Basically, I want to get the first items base don the url. Then that data, actually determines what gets loaded in the next one, since they both contain entry_id. My problem right now is the second just starts all fresh, and grabs everything. I am pulling my hair out on this one...

Also, is there a way I could pass all the results into one nice $data value?


Query Problem (Multiple Tables) - El Forum - 07-19-2008

[eluser]ywftdg[/eluser]
Wow, somehow answered this one my own, pulled this out my...

Code:
$this->db->where('field_id_8', $this->uri->segment(1));
$this->db->select('*');
$this->db->from('exp_weblog_data','exp_weblog_titles');
$this->db->join('exp_weblog_titles', 'exp_weblog_titles.entry_id = exp_weblog_data.entry_id');
$data['query']=$query = $this->db->get();