$threadarray = $vbulletin->db->query_read(" SELECT thread.*, icon.title AS icontitle, icon.iconpath AS iconpath, user.username, user.userid, user.usergroupid, IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid
FROM " . TABLE_PREFIX . "thread AS thread LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = thread.iconid) LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.username = thread.postusername) WHERE thread.threadid IN($tindex) $pqr ORDER BY $sqlsort$sortorder$secondarysortsql LIMIT " . ($limitlower - 1) . ", $perpage ");