[eluser]whobutsb[/eluser]
[quote author="CuongVM" date="1234867285"]Hi everyone,
I have this SQL statement :
Select * from `abc_table` abc
where abc.field1 = 1 and
(
abc.field2 = 2 and
(abc.field = 3 or abc.field4 = 4)
);
If don't use $this->db->query() statement, how do I write this statement (by $this->db->where...)
Thanks for helping.[/quote]
Code:
$this->db->select('*');
$this->db->where('abc.field1', 1);
$this->db->where('abc.field2', 2);
$this->db->where('(abc.field3 = 3 OR abc.field4 = 4)');
$query = $this->db->get('abc_table')
return $query->result();
You can either write your where statement in key/value pairs like I did with fields 1 and 2 or you can write your entire where statement right in to the $this->db->where() method. Either way works just fine.
Steve