$selectstring = "SELECT library.id, library.media_type, library.media_id," .
"cc.title AS category, library.published, library.hits, library.checked_out, library.catid, ".
" library.informationFrom, l.id as lendid, l.lend_from as lend_from, " .
" l.lend_return as lend_return, other_table.ext1 as artist " .
" l.lend_until as lend_until ," .
" u.name AS editor, " .
" other_table.id as media_type_id, other_table.title as title " .
" FROM #__medialibrary AS library " .
" left join #__categories AS cc on cc.id = library.catid " .
" left join #__medialibrary_lend AS l on library.fk_lendid = l.id " .
" left join #__users AS u on u.id = library.checked_out, " .
" LEFT JOIN (SELECT id, title, 'game' as type, comment, studio as ext1, binding as ext2, platform as ext3 FROM #__medialibrary_game ".
" UNION all SELECT id, title, 'music' as type, comment,artist as ext1, label as ext2, tracklist as ext3 FROM #__medialibrary_music " .
" UNION all SELECT id, title, 'book' as type,comment,authors as ext1, manufacturer as ext2, edition as ext3 FROM #__medialibrary_book " .
" UNION all SELECT id, title, 'video' as type, comment,actors as ext1, producers as ext2, format as ext3 FROM #__medialibrary_video) " .
" AS other_table ON other_table.id = library.media_id and other_table.type = library.media_type" .
" WHERE library.id IN (" . $bids . ") AND fk_lendid = 0" .
" ORDER BY library.catid, ordering";
|