Jump to content
  • 0

Support on SQL.


Question

Posted (edited)

Hi guys another question regarding SQL, can anyone help me or teach me how to choose top 3 from a specific column in sql?

And later on claim their price by getting it to specific  NPC?

 

Am here right now:

query_sql "select pool from `system_system` order by pool DESC LIMIT 3",.@placer;

Now the next part is? IDK what to do. XD

 

Also I would like to know how to delete a specific values from a table in sql:

Like this: I would only like to delete the value not the table.

query_sql(DELETE FROM system_system WHERE pool

or this? I cant make both work. :(

query_sql "REPLACE INTO `system_system` (`pool`) VALUES ('0')
Edited by Lil Troll

3 answers to this question

Recommended Posts

Posted (edited)

1.

prontera,180,150,4%TAB%script%TAB%npc_name%TAB%123,{
set .@a,getcharid(0);
if( .@placer[0] == .@a || .@placer[1] == .@a || .@placer[2] == .@a )
    {getitem .reward,1; query_sql("DELETE FROM `system_system` WHERE `pool`='"+ .@a +"'"); end;}
dispbottom "Only the Top 3 can receive a reward.";
end;

OnClock0000: //Once a day do this.
query_sql("SELECT `pool` from `system_system` ORDER BY `pool` DESC LIMIT 3",.@placer);
end;
}

Your problem, was you weren't specifying exactly where to delete.

Edited by Lionhardt
  • Upvote 1
Posted

I'm a bit rusty, but let me try ^^

 

query_sql "SELECT `pool` FROM `system_system` ORDER BY `pool` DESC LIMIT 3", @pool;

@pool[0]; // -> value 1
@pool[1]; // -> value 2
@pool[2]; // -> value 3
query_sql "DELETE FROM `system_system` WHERE `pool`='" + @value + "'";
query_sql "UPDATE `system_system` SET `pool` =  '" + @newValue + "' WHERE `id` = '1'";

 

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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