$query = $db->query('
SELECT t.*, f.name, a.updatetime, a.md5hash, a.uploadtime, a.aid, a.attachname, a.filename
FROM '.TABLE_PREFIX.'threads t
LEFT JOIN '.TABLE_PREFIX.'xtattachments a ON (a.tid=t.tid)
LEFT JOIN '.TABLE_PREFIX.'forums f ON (f.fid=t.fid)
WHERE t.visible=1 AND t.uid='.intval($memprofile['uid']).' AND closed NOT LIKE "moved|%" AND t.fid IN ('.implode(',', $mnxtigp_fid_array).')'.$mnxtigp_unviewwhere.'
'.$mnxtigp_lr.'
GROUP BY a.tid
LIMIT 0,'.intval($mybb->settings['mnxtigp_num']).'
But its giving me a syntax error. I tried putting the group thing in other places in the code but failed :/