我有两个表,即 Table1 和 Table2,并且我使用 Table1.PrimaryKey = Table2.ForeignKey 在 Table2 上左连接 Table1。它确实返回两个表中的所有行,但在某些行中,由于表 2 中没有用于连接条件的记录,因此表 1 中缺少 PrimaryKey 字段值。这是我的代码
$this->db->select('*');
$this->db->from('CI_Articles_Tbl');
$this->db->join('CI_Article_Images_Tbl',
'CI_Articles_Tbl.roflArticle_ID=CI_Article_Images_Tbl.roflArticle_ID','left');
$this->db->group_by('CI_Articles_Tbl.roflArticle_ID');
$query = $this->db->get();
return $query->result_array();
我的查询中存在什么问题以及可能的解决方案是什么。 任何帮助将不胜感激。
最佳答案
您已选择table.*
试试这个代码。
$this->db->select('CI_Articles_Tbl.*');
关于php - CodeIgniter 两个表Left Join在右表缺失时不返回左表的Join Condition id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20418791/