Jump to content

Sotring a db Table


'LinKin

Recommended Posts

Posted

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

Posted

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 

Posted
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.

Posted

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))

Posted
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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...