How can I generate embedded query? |
[eluser]MDomansky[/eluser]
Hi, How can I generate embedded query like Code: select * from (select * from table where id> 100) where role = 3 Thank you in advice
[eluser]zutis[/eluser]
Is this what you are after ... Code: $query = $this->db->query('select * from (select * from table where id> 100) where role = 3');
[eluser]TheFuzzy0ne[/eluser]
Do you really need a subquery? Code: SELECT * FROM `table` WHERE `id` > '100' AND `role` = '3'; If you're referring to the Active Record class, I'm not sure if it's possible. It appears to be designed with only single-level queries in mind, so you'd be better off just firing your query at the database directly.
[eluser]MDomansky[/eluser]
Thanks, 1) I posted the query only for example. Actually, I have more difficult one 2) Yes, I'm looking for solution referring to Active Records. Early, I saw something like that: $this->db->select('name')->from('table')->where(); $embedded_sql = $this->db->query; $this->db->clear(); $this->db->select('name')->from($embedded_sql)->where()->get;
[eluser]TheFuzzy0ne[/eluser]
I wonder if this will help you - http://ellislab.com/forums/viewthread/87508/ |
Welcome Guest, Not a member yet? Register Sign In |