mysql max函数使用的注意点
SELECT id,visits FROM `zentao`.`zt_user`
SELECT id,max(visits) FROM `zentao`.`zt_user`
如下图:结果查出的id不是max对应的id
应该改为
SELECT id,visits FROM `zentao`.`zt_user` where visits = (SELECT max(visits) FROM `zentao`.`zt_user`) limit 1 SELECT id,visits FROM `zentao`.`zt_user` order by visits desc limit 1