SELECT `主表`.id, `主表`.title, `辅表`.* FROM tableB AS `辅表` INNER JOIN tableA AS `主表` ON `主表`.id = `辅表`.firm_id WHERE #子查询判断该行是否需要取出,最大一条的count为0 次大一条的count为1,其余不满足条件 所以不读取 (SELECT COUNT(`辅表2`.create_time) FROM tableB AS `辅表2` WHERE `主表`.id = `辅表2`.firm_id AND `辅表2`.create_time > `辅表`.`create_time`) < 2 ORDER BY `主表`.id, `辅表`.create_time DESC
取最大一条能用max,取第二大的就不需要用max函数了。。。。