I want to do an inner join with codeigniter and i have tried a lot but no success.
Mysql code for inner join,
SELECT * FROM shop INNER JOIN city ON city.city_id = shop.city_id WHERE city.city_name = 'Bangalore'
The above sql query is working perfectly in phpmyadmin. While converting this code in codeigniter it is not working.
Codeigniter code is,
$this->db->select('*');
$this->db->from('shop');
$this->db->join('city', 'city.city_id = shop.city_id');
$query = $this->db->where('city', array('city.city_name' => 'Bangalore'));
if($query->num_rows() > 0) {
return $result = $query->result_array();
}
else {
return 0;
}
where am going wrong. am beginner in codeigniter.