如果要找到字段数据,我想要我想要的代码,然后我想要将该特定数据连接到另一个表。
$this->db->select('*');
$this->db->from('userprofile');
$this->db->where('userId', $userId);
$this->db->where('status', 1);
$this->db->join('bodytype', 'bodytype.bodyTypeId = userprofile.bodyType');
$this->db->join('children', 'children.childrenId = userprofile.children');
$this->db->join('ethnticity', 'ethnticity.ethnticityId = userprofile.ethnicity');
$this->db->join('smoke', 'smoke.smokeId = userprofile.smoke');
$this->db->join('drink', 'drink.drinkId = userprofile.drink');
$query = $this->db->get();
return $query->result();
如果我先得到了userprofile.bodyType,然后又运行了bodytype joinquery,有什么方法可以处理吗?
答案 0 :(得分:0)
来自此堆栈: Value IS NOT NULL in codeigniter
添加此where子句进行查询
$this->db->where('bodyType is NOT NULL', NULL, FALSE);
答案 1 :(得分:0)
尝试INNER JOIN:
$this->db->join('bodytype', 'bodytype.bodyTypeId = userprofile.bodyType','inner');