query('SELECT * FROM answers INNER JOIN questions
WHERE answers.answerId= questions.questionId AND answers.answerId IN (' . $id . ')')
我需要帮助才能将此更改为codeigniter的活动记录。
我试图从两个表中获取等于id的值并加入它。但当我尝试这样的时候
$this->db->select("*"); $this->db->join("questions","questions.questionId = answers.answerId"); $this->db->where_in('answers.answerId',$id); $res = $this->db->get("answers");
它只显示通过id传递的第一个连接表。
答案 0 :(得分:0)
试试这个
$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();
答案 1 :(得分:0)
默认情况下,其内连接
$this->db->select("*");
$this->db->join("questions","questions.questionId = answers.answerId");
$this->db->where_in('answers.answerId',$id);
$res = $this->db->get("answers");