代码点火器活动记录“内部”连接


codeigniter active record 'inner' join

query('SELECT * FROM answers INNER JOIN questions 
      WHERE answers.answerId= questions.questionId AND answers.answerId IN (' . $id . ')')

我需要帮助将其更改为代码点火器的活动记录。

我试图从两个表中获取等于 id 的值并连接它。 但是当我像这样尝试时

$this->db->select("*"); $this->db->join("questions","questions.questionId = answers.answerId"); $this->db->where_in('answers.answerId',$id); $res = $this->db->get("answerswers"); 

它仅显示通过 id 传递的第一个联接表。

试试这个

    $this->db->select('*');
    $this->db->from('answers'); 
    $this->db->join('questions','questions.questionId=answers.answerId');
    $this->db->where_in('answers.answerId',$id);
    $query=$this->db->get();
    $result=$query->result();

默认情况下,其内部连接

 $this->db->select("*");
 $this->db->join("questions","questions.questionId = answers.answerId");
 $this->db->where_in('answers.answerId',$id);
 $res = $this->db->get("answerswers");