【问题标题】:Codeigniter Join If the value is not NULLCodeigniter Join 如果值不为 NULL
【发布时间】:2018-10-30 13:00:18
【问题描述】:

如果我找到了字段数据,我想要代码,然后我想将该特定数据连接到另一个表。

    $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 运行。有什么办法来处理它?

【问题讨论】:

    标签: javascript php codeigniter join


    【解决方案1】:

    来自这个堆栈: Value IS NOT NULL in codeigniter

    添加这个 where 子句来查询

    $this->db->where('bodyType is NOT NULL', NULL, FALSE);
    

    【讨论】:

      【解决方案2】:

      尝试 INNER JOIN :

      $this->db->join('bodytype', 'bodytype.bodyTypeId = userprofile.bodyType','inner');
      

      【讨论】:

        猜你喜欢
        • 2016-01-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-26
        • 1970-01-01
        • 2017-09-27
        • 1970-01-01
        相关资源
        最近更新 更多