'LinKin Posted February 18, 2014 Share Posted February 18, 2014 Hello, I use the SQL functions by default for MTA. I have a table. I want it so that when a player clicks Tops>SelectedValue* Note: SelectedValue is the column which you want to recieve tops of. (1st, 2nd, 3rd, Playtime, etc..) It shows the Top 10 players regarding the SelectedValue. How can I make this? Sort the table by the selected column and printing the first 10 lines? Or anyother way? Thanks Link to comment
Castillo Posted February 18, 2014 Share Posted February 18, 2014 Depends on how you are storing these values. You can use "ORDER BY" in the query. Example: SELECT account, myValue FROM myTable ORDER BY myValue DESC LIMIT 10 Link to comment
Bonsai Posted February 18, 2014 Share Posted February 18, 2014 local result = executeSQLQuery("SELECT playerName, timeText, dateRecorded, extra FROM ? ORDER BY timeMS ASC LIMIT 10", mapname ) This is what I do in my toptimes script. Link to comment
'LinKin Posted February 18, 2014 Author Share Posted February 18, 2014 So ASC Ascendent order DESC Descendent order LIMIT : Number of results to display? (i.e. 1st ten tops = LIMIT 10) Thanks a lot Solid and Bonsai, let's live together bons)) Link to comment
'LinKin Posted February 21, 2014 Author Share Posted February 21, 2014 local result = executeSQLQuery("SELECT playerName, timeText, dateRecorded, extra FROM ? ORDER BY timeMS ASC LIMIT 10", mapname ) This is what I do in my toptimes script. If I wanted to sort the the entire table, (without limit) would I be able to do so just by deleting "LIMIT 10" from the Query? Link to comment
Castillo Posted February 21, 2014 Share Posted February 21, 2014 That won't limit to sort only 10, it'll limit the amount of rows it'll return. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now