Reputation: 174
I am trying to write a join query but its not working.
this is my model
public function select_debate($channel_id)
{
$this->db->select('*');
$this->db->from('TN_biaso');
$this->db->join('TN_show', 'TN_show.show_id = TN_biaso.biaso_id', 'left');
$this->db->where('channel_name', $channel_id);
$query = $this->db->get();
return $query->result();
}
Upvotes: 3
Views: 47
Reputation: 219
try like this in your where condition if your channel_name column in TN_biaso table
public function select_debate($channel_id)
{
$this->db->select('*');
$this->db->from('TN_biaso');
$this->db->join('TN_show', 'TN_show.show_id = TN_biaso.biaso_id', 'left');
$this->db->where('TN_biaso.channel_name', $channel_id);
$query = $this->db->get();
return $query->result();
}
or if your channel_name column in TN_show table
public function select_debate($channel_id)
{
$this->db->select('*');
$this->db->from('TN_biaso');
$this->db->join('TN_show', 'TN_show.show_id = TN_biaso.biaso_id', 'left');
$this->db->where('TN_show.channel_name', $channel_id);
$query = $this->db->get();
return $query->result();
}
Upvotes: 0
Reputation: 1617
I think your where clause is getting an ambigious column channel_name
. Try writing the table_name
.column_name
in the where clause just like in your join clause. i.e TN_biaso.channel_name
or TN_show.channel_name
Upvotes: 0
Reputation: 121
Use
echo $this->db->last_query(); exit;
Copy the query and test it in phpmyadmin, it tells you whether you have any error in your query or not. let me know after the result. cheers!!
Upvotes: 1