gpt4 book ai didi

mysql - 如何在 codeigniter 中编写左连接查询?

转载 作者:太空宇宙 更新时间:2023-11-03 12:20:22 25 4
gpt4 key购买 nike

谁能告诉我如何在 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

关于mysql - 如何在 codeigniter 中编写左连接查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20367178/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com