Question

Using: MYSQL

So, i have this problem. I have a Table called tblUser, and this table has a level colum, so i need to get the level of one user, for example,


id: 1
User: Pancho Villa
Level: 15.

So i need to get the 9 register more who's level is below him and i don't have any idea how... so, this is an example, i get the ID of Pancho Villa:

id: 1
User: Pancho Villa  
Level: 15  

id: 25
User: Emiliano Zapata  
Level: 15

id: 14
User: Porfirio Díaz   
Level: 14

id: 7
User: Subcomandante Marcos<br>
Level: 13

& 6 more results

Was it helpful?

Solution 2

Try this SQL

SELECT user,level
FROM tblUser
WHERE level <= (
    SELECT level
    From tblUser
    WHERE user = 'Pancho Villa'
)
AND user != 'Pancho Villa'
ORDER BY level DESC
LIMIT 9

OTHER TIPS

Try something like this:

select `User`,`Level` from tblUser where `Level` <= 15 Order by `Level` DESC
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top