greeting!, have little problem sql query, need join several "or" on parenthesis.. , don't know how that.. example:
select a.a1, b.b1, c.c1 inner join b on a.a1=b.b1 inner join c on a.a1 = c.c1 c.c2='t' , ( a.a1 %xxxx% or b.b1 %xxxx% )
and wrote on codeigniter code
$this->db->select("a.a1, b.b1, c.c1"); $this->db->where("c.c2",'t'); $this->db->like("a.a1", $match); $this->db->or_like("b.b1", $match); $this->db->join("b","a.a1 = b.b1",'inner'); $this->db->join("c","a.a1 =c.c1",'inner');
but output, , isn't want
select a.a1, b.b1, c.c1 inner join b on a.a1=b.b1 inner join c on : a.a1 = c.c1 c.c2='t' , a.a1 %xxxx% or b.b1 %xxxx%
$this->db->select("a.a1, b.b1, c.c1"); $this->db->where("c.c2",'t'); $this->db->group_start(); // ( $this->db->like("a.a1", $match); $this->db->or_like("b.b1", $match); $this->db->group_end(); // ) $this->db->join("b","a.a1 = b.b1",'inner'); $this->db->join("c","a.a1 =c.c1",'inner');
Comments
Post a Comment