Home > Database > Mysql Tutorial > body text

mysql常用_MySQL

WBOY
Release: 2016-06-01 13:06:58
Original
952 people have browsed it

1、mysql 分组取前N记录

select present_price,userid from wx_goods a where 2 > (select count(*) from wx_goods where userid=a.userid and present_price>a.present_price) GROUP BY present_price ORDER BY userid,present_price desc

其中 GROUP BY present_price 是为了去除因比较值重复的情况发生

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template