Welcome Guest, Not a member yet? Register   Sign In
Quick question regarding where_in/where_not_in Active Record
#1

[eluser]xzela[/eluser]
I've checkout the documentation for both CodeIgniter and MySQL regarding the where_in/where_not_in clause and I'm having trouble using it within the Active Record Class.

The MySQL documents state that sub queries can be ran within a WHERE IN/NOT IN clause, such as this:
Code:
SELECT * FROM table WHERE table.id NOT IN (SELECT other.id FROM other);
More can be found here: http://dev.mysql.com/doc/refman/5.0/en/a...eries.html

However if one uses that same query with active record:
Code:
$this->db->from('table');
$this->db->where_not_in('table.id', 'SELECT other.id FROM other');

it will produce this:
Code:
SELECT *
FROM ('table')
WHERE 'table'.'id' NOT IN ('SELECT other.id FROM other')

Those quotes around the NOT IN('SELECT ...') prevent the sub query from running. Is it possible to remove those single quotes without modifying the core too much? or should i just hand write the query?

Has anyone else ever encountered this?

Let me know what you guys think.


Messages In This Thread
Quick question regarding where_in/where_not_in Active Record - by El Forum - 01-28-2009, 04:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB