谁能告诉我如何在 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)
试试这个
$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','左')->join('t4','t4.c = t1.c','左');
引用:http://ellislab.com/codeigniter/user-guide/database/active_record.html
我是一名优秀的程序员,十分优秀!