select name,class,age,sex from ta order by age desc limit 0,1
select name,class,max(age),sex from tA group by class你再查查,这句确实符合你的要求,不会多出来记录。
Sorry,Mysql的product 4.0.17版不支持子查询 估计一句sql弄不出来的;Mysql 5.0的可以这样select * from table1 where age in(select max(age) from table1);
Sorry,Mysql的product 4.0.17版不支持子查询 估计一句sql弄不出来的;Mysql 5.0的可以这样 改一哈 select * from table1 where age in(select max(age) from table1 group by class);
试试看 select max(age) as aa, name, Calss, sex from orders group by Calss, sex, name order by Calss, aa desc
多语句实现begin; create TEMPORARY table tmp2 select class,max(age) as age from tmp group by class; select a.* tmp from tmp a join tmp2 b on a.class=b.class and a.age=b.age; commit;
估计一句sql弄不出来的;Mysql 5.0的可以这样select * from table1 where age in(select max(age) from table1);
估计一句sql弄不出来的;Mysql 5.0的可以这样
改一哈
select * from table1 where age in(select max(age) from table1 group by class);
select max(age) as aa, name, Calss, sex
from orders
group by Calss, sex, name
order by Calss, aa desc
create TEMPORARY table tmp2 select class,max(age) as age from tmp group by class;
select a.* tmp from tmp a join tmp2 b on a.class=b.class and a.age=b.age;
commit;
斑竹整理的FAQ大家要多多看哦。