有人可以告诉我如何在codeigniter中编写这个mysql查询吗?
SELECT * FROM t1 LEFT JOIN (t2, t3, t4)
ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)
答案 0 :(得分:3)
试试这个
$this->db->select(*);
$this->db->from('t1');
$this->db->join('t2','t2.a = t1.a','left');
$this->db->join('t3','t3.b = t1.b','left');
$this->db->join('t4','t4.c = t1.c','left');
或者(浓缩)
$this->db->select(*)->from('t1')->join('t2','t2.a = t1.a','left')->join('t3','t3.b = t1.b','left')->join('t4','t4.c = t1.c','left');
参考:http://ellislab.com/codeigniter/user-guide/database/active_record.html