gpt4 book ai didi

mysql - Codeigniter 查询生成器类

转载 作者:行者123 更新时间:2023-11-29 11:05:50 25 4
gpt4 key购买 nike

我是使用 codeigniter 查询生成器类的初学者。我在使用查询生成器类转换此查询时遇到了问题。

SELECT tb_country.`countryName`, COUNT(tb_country.countryId) AS totalCustomer FROM tb_customer 
JOIN tb_city ON tb_city.`cityId` = tb_customer.`cityId`
JOIN tb_state ON tb_state.`stateId` = tb_city.`stateId`
JOIN tb_country ON tb_country.`countryId` = tb_state.`countryId`
GROUP BY tb_country.`countryName`

任何答案都会对我有帮助,提前谢谢!

最佳答案

$this->db
->select("tb_country.countryName, COUNT(tb_country.countryId) AS totalCustomer", false)
->from('tb_customer')
->join('tb_city', 'tb_city.cityId = tb_customer.cityId')
->join('tb_state', 'tb_state.stateId = tb_city.stateId')
->join('tb_country', 'tb_country.countryId = tb_state.countryId')
->group_by('tb_country.countryName')
->get()
->result();

关于mysql - Codeigniter 查询生成器类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41417173/

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