Home > database >  The MySQL database
The MySQL database

Time:09-30

If have a result table, how to query the top three?

CodePudding user response:

Select * from TB limit 0, 2

CodePudding user response:

Select * from TB limit 0, 2 upstairs, return all of the data of the first three lines should be combined with an order by statement sort

Select * from record table order by desc score limit 0, 2

Order by desc score according to get ranked in descending order [999-0]
The order by asc scores according to ascending order must be made respectively [0-999]

CodePudding user response:

Select * from record table order by scoring desc limit 3

CodePudding user response:

SELECT
*
The FROM
Score
The ORDER BY
Score DESC
LIMIT 3

CodePudding user response:

Select * from record table order by grades desc limit 3;

Can also be changed to:
Select * from record table order by grades desc limit 0, 3;

Limit and limit 3 0, 3 effect is consistent,

On personal public number "andyqian", recently updated to many MySQL related articles, index optimization, have LIMIT optimization, may be helpful to you!




CodePudding user response:

Select
*
From table
The order by the score
Desc limit 3;

CodePudding user response:

Select * from score record table order by desc limit 0, 3;
  • Related