CodeIgniter Forums

Full Version: $this->db->where
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I do a $this->db->where for a field where I want it to set to  a or b or c? Do I need three seperate where staements for the same field?

Thanks
That depend on the type of the condition.
is this either: WHERE id=a OR id=b OR id=c
or: where id=a AND id=b AND id=c
or: where id IN (a,b,c)

Have a look at the tutorial:
https://www.codeigniter.com/userguide2/d...tml#select
look at or_where, where_in, etc depending on what you try to do
(05-25-2017, 08:24 AM)rtenny Wrote: [ -> ]That depend on the type of the condition.
is this either: WHERE id=a OR id=b OR id=c
or: where id=a AND id=b AND id=c
or: where id IN (a,b,c)

Have a look at the tutorial:
https://www.codeigniter.com/userguide2/d...tml#select
look at or_where, where_in, etc depending on what you try to do

WHERE id=a OR id=b OR id=c is what I meant


Thanks
(05-25-2017, 08:33 AM)Knutsford Wrote: [ -> ]WHERE id=a OR id=b OR id=c is what I meant


Thanks


the I would use this

Code:
$names = array('a', 'b', 'c');
$this->db->where_in('username', $names);
$this->db->where_in worked - thanks