if coulmn of mysql is empty you get value from other table with same name of coulmn in codeigniter if coulmn of mysql is empty you get value from other table with same name of coulmn in codeigniter codeigniter codeigniter

if coulmn of mysql is empty you get value from other table with same name of coulmn in codeigniter


Assuming the column name is name

 $this->db->select('coalesce(w.name, t.name) as tournament_name, w.tournament_id,<all other tournament_week fields>');


COALESCE function should work.Try following.

    $this->db->select('COALESCE(w.name, t.name) tournament_name);                $this->db->from('tournament_week w');                $this->db->join('tournament t', 'w.tournament_id = t.id');                $this->db->where('w.tournament_id=', $tid);                $this->db->where('w.show_week', 1);                $this->db->order_by("w.week_no", "ASC");         $query = $this->db->get()->result_array();    return $query;