有表t如下:
id(auto) customerID num ...
13 1 12 ...
14 1 15 ...
15 2 14 ...
16 2 10 ...
17 4 14 ... 我怎样得到按customerID取得ID最大的记录集
(结果是每个customerID只对应一条最新记录)如: id(auto) customerID num ...
14 1 15 ...
16 2 10 ...
17 4 14 ...
mysql4.0不支持嵌套查询?
id(auto) customerID num ...
13 1 12 ...
14 1 15 ...
15 2 14 ...
16 2 10 ...
17 4 14 ... 我怎样得到按customerID取得ID最大的记录集
(结果是每个customerID只对应一条最新记录)如: id(auto) customerID num ...
14 1 15 ...
16 2 10 ...
17 4 14 ...
mysql4.0不支持嵌套查询?
where not exists (select id from t where customerID=t.customerID and id>t.id);
inner join
(select customerID,max(id) as ma from tt group by customerID) b
on a.customerID=b.customerID and a.id=b.ma