MySQL Order By 用法

ORDER BY uid ASC

按照uid正序查询数据,也就是按照uid从小到大排列

ORDER BY uid DESC

按照uid逆序查询数据,也就是按照uid从大到小排列

 

例子:select * from test where uid=1 order by id desc limit 1; 逆序查询,查最后一个uid=1的行

   select * from test where uid=1 order by id asc limit 1; 正序查询,查uid=1的第一行 

你可能感兴趣的:(mysql,mysql)