SELECT a. * , t. * , count( DISTINCT a.tid ) FROM eucom_bbs.cdb_attachments a, eucom_bbs.cdb_threads t WHERE a.tid IN ( SELECT t.tid FROM eucom_bbs.cdb_threads t WHERE t.attachment =2 ORDER BY dateline DESC ) GROUP BY a.tid
SELECT * FROM Discuz710.cdb_posts p INNER JOIN Discuz710.cdb_attachments a ON p.tid = a.tid AND p.authorid = a.uid WHERE a.isimage =1 GROUP BY p.tid ORDER BY p.dateline DESC