CodeIgniter Forums
Nested selects with Active Record - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Nested selects with Active Record (/showthread.php?tid=39131)



Nested selects with Active Record - El Forum - 03-01-2011

[eluser]dangermark[/eluser]
Hi all,

Is it possible to do nested select queries in Active Record?

Something that would generate:

Code:
SELECT * FROM table1 WHERE id IN (SELECT id FROM table2)

If it's not possible, an idea (or link) on the best way to accomplish this in CI would be great.

Thanks for your time.


Nested selects with Active Record - El Forum - 03-02-2011

[eluser]seeraw[/eluser]
You can use instead

$this->db->query(‘YOUR NESTED QUERY HERE’);

Thanks,
Swapnil


Nested selects with Active Record - El Forum - 03-02-2011

[eluser]InsiteFX[/eluser]
Or maybe a join!

InsiteFX


Nested selects with Active Record - El Forum - 03-02-2011

[eluser]dangermark[/eluser]
[quote author="seeraw" date="1299067960"]You can use instead

$this->db->query(‘YOUR NESTED QUERY HERE’);

Thanks,
Swapnil[/quote]

Cool, that'll work fine, just wasn't sure if there was another way.