类似于select * from test group by name 和select * from test group phone 的结果的聚合
被看到过滤phone啊 再说了 我的版本好像不支持子查询的 会报错
select a.* from tt a inner join (select name,max(id) as ma from tt group by name) b on a.name=b.name and a.id=b.ma group by a.phone 在高版本的mysql中是支持的吧 我的mysql版本太低了 3.23.58
将select name,max(id) as ma from tt group by name生成临时表,再与工作表连接
本帖最后由 yueliangdao0608 于 2008-11-18 08:56:44 编辑
create table newtt as select name,max(id) as ma from tt group by name
CREATE TEMPORARY TABLE tmp_test select id from test group by name
和select * from test group phone 的结果的聚合
再说了 我的版本好像不支持子查询的 会报错
inner join (select name,max(id) as ma from tt group by name) b
on a.name=b.name and a.id=b.ma group by a.phone 在高版本的mysql中是支持的吧
我的mysql版本太低了 3.23.58
as
select name,max(id) as ma from tt group by name