I want to join tables to list books of two categories fiction and romance. How do I do a JOIN with a WHERE IN clause (is that even possible? sorry, noob here)
Here's where I'm stuck at:
$categories = array(10,12);
$query = select()->from('books');
$query->join('genre_map','genre_map.gid IN ('.implode(",", $categories).')');
Jn Table genre_map: bookid, genre_id
Any SQL Query/CodeIgniter help would be much appreciated.
never used codeigniter, but I would say
$categories = array('10', '12');
$this->$db->select('*');
$this->$db->from('books');
$this->$db->join('genre_map','genre_map.bookid = books.bookid');
$this->$db->where_in('genre_map.gid', $categories);
$query = $this->db->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With