开发者

How to get 2nd highest from table?

I have a table like this:

id  | name | class | marks 
 1  | abc  |  1 开发者_JAVA百科   | 90
 2  | cdf  |  1    | 100  
 3  | xyz  |  1    | 70 

I want to get 2nd highest marks record. How can I get it with with one query. Simple and short?


SELECT * FROM `tableName` ORDER BY `marks` DESC LIMIT 1,1


Use LIMIT and ORDER

SELECT * FROM table
ORDER BY marks DESC LIMIT 1,1

ORDER BY marks DESC means: descending ordering, so highest on top. LIMIT 1,1 means offset = 1 and only select 1 row.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜