gpt4 book ai didi

php - Codeigniter Active Record HAVING/WHERE db.field = db.field

转载 作者:可可西里 更新时间:2023-11-01 07:20:35 24 4
gpt4 key购买 nike

谁能告诉我,这是否可以通过事件记录来实现?如何实现?

$this->db->select('*');
$this->db->from('table1');
$this->db->join('table2', 'table1.id = table2.fi_id', 'left');
$this->db->having('table1.second_id','table2.fi_second_id', false);
$query = $this->db->get();

问题在于,'table2.fi_second_id' 始终被视为字符串 - 而不是数据库字段。也用'where'试过这个 - 这是同样的问题。

谢谢

最佳答案

我认为您想要以下内容:

$this->db->having('table1.second_id = table2.fi_second_id',false);

如果您不需要转义的 SQL 查询,您可以应用也可以不应用 false 参数。

关于php - Codeigniter Active Record HAVING/WHERE db.field = db.field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15360036/

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