取所有分类下最新的一条记录 写道 CREATE TABLE `p2` ( `tid` int(11) NOT NULL, `p1_id` int(11) NOT NULL, `dt` date NOT NULL, PRIMARY KEY (`tid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE `p1` ( `id` int(11) NOT NULL, `name` char(20) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 SELECT a.*,b.cp_name FROM ( SELECT * FROM company_allot ORDER BY `created` DESC ) AS a LEFT JOIN company AS b ON a.cp_id=b.cp_id GROUP BY cp_id order by `created` ASC