Jump to content
  • 0
Jedzkie

Help on 'rand' in Query SQL

Question

hi how can I randomly set cash point to my account using query_sql?

 

example:

query_sql ("UPDATE `cash` SET `cash_point` = cash_point + rand(100,1000) WHERE `account_id` = '"+getcharid(3)+"'");

 

if i use the item, this is the error. DB error - Operand should contain 1 column(s)

 

Thanks!

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

@@Frost When you run a SELECT query, you must pass variables to store the returned data.

query_sql("SELECT `cash_point` FROM `cash` WHERE `account_id` = "+getcharid(3), .@newCash);dispbottom "Now you have " + .@newCash;

Share this post


Link to post
Share on other sites
  • 0

 

query_sql ("UPDATE `cash` SET `cash_point` = " + rand(100,1000) + " WHERE `account_id` = " + getcharid(3));

 

please note that it will just change the current (entire) value to a random amount, instead of increasing it

Share this post


Link to post
Share on other sites
  • 0

 

 

query_sql ("UPDATE `cash` SET `cash_point` = " + rand(100,1000) + " WHERE `account_id` = " + getcharid(3));

 

please note that it will just change the current (entire) value to a random amount, instead of increasing it

 

actually you're right, i forgot to say that randomly increase, but i already fixed it. Thanks BTW

 

Well, he did say "randomly set", not "randomly increase", thus I changed it accordingly :o

 

Hi Garr! thanks for the quick response, how about a message to tell how much Points you get?

 

Edit:

NvM I figured it out the message of how many points you get, but I want to add another message that tells what is the total points in your account.

 

example: query_sql("SELECT `cash_point` FROM `cash` WHERE `account_id` = "+getcharid(3));

 

is this right? i have a error message after executing this script. 'script:query_sql: Too many columns. discarding last 1 columns.'

Edited by Frost

Share this post


Link to post
Share on other sites
  • 0

 

@@Frost When you run a SELECT query, you must pass variables to store the returned data.

query_sql("SELECT `cash_point` FROM `cash` WHERE `account_id` = "+getcharid(3), .@newCash);dispbottom "Now you have " + .@newCash;

 

Thanks!

Share this post


Link to post
Share on other sites

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

  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.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.