I have 2 questions:
$genres = $this->db->select('Group_Concat(intGenreId) strDJGenres') ->from('tblDJGenres') ->where('intDJId', $this->session->userdata('non_admin_userid')) ->get() ->row(); $results = $this->db->select('tblTracks.*, tblGenres.strName as strGenreName') ->from('tblTracks') ->join('tblGenres', 'tblTracks.intGenreId = tblGenres.intGenreId', 'left') ->where_in('tblTracks.intGenreId', $genres->strDJGenres) ->get() ->result();
The first query returns a string such as
'1,2,3,4,8,6,5,7,45,66'
which I use in my where_in clause in the second query. The problem is that with this line he writes SQL as:
SELECT `tblTracks`.*, `tblGenres`.`strName` as strGenreName FROM (`tblTracks`) LEFT JOIN `tblGenres` ON `tblTracks`.`intGenreId` = `tblGenres`.`intGenreId` WHERE `tblTracks`.`intGenreId` IN ('1,2,3,4,8,6,5,7,45,66')
When quoting around it, it is considered as one value. How can I get a second request to execute as I want? those.
.... where `tblTracks`.`intGenreId` IN (1,2,3,4,8,6,5,7,45,66)
source share