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

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

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?

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted

That won't limit to sort only 10, it'll limit the amount of rows it'll return.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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