0

I want the code that I if I found the field data then I want to join that particular data to another table.

    $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();

If I got the userprofile.bodyType then and then the bodytype joinquery run.Is there any way to handle it?

2 Answers2

0

from this stack: Value IS NOT NULL in codeigniter

add this where clause to query

$this->db->where('bodyType is NOT NULL', NULL, FALSE);
essam eg
  • 109
  • 5
0

Try INNER JOIN :

$this->db->join('bodytype', 'bodytype.bodyTypeId = userprofile.bodyType','inner');
Manoj Singh
  • 253
  • 1
  • 7