SA-MP Forums Archive
Simple SQL question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Simple SQL question (/showthread.php?tid=249584)



Simple SQL question - KaleOtter - 19.04.2011

Ey
Normaly you use:

SET Money='$money'

But now I need to count the $money together with the money he already has.

So like SET Money=+'$money' should it be in PAWN.
But this doesn't work, somebody know how to do this?


Re: Simple SQL question - Alby Fire - 19.04.2011

Pawn ain't the same as PHP, to format a variable you have to use "%" and a letter to indicate wich variable you're gonna use, then do
Код:
SET `Money`+= '%d'
For example
pawn Код:
new
    s[100], variable = 5;
format(s, sizeof s, "UPDATE `table` SET `Money`= '%d' WHERE `field` = '1'", variable);
mysql_query(s);



Re: Simple SQL question - Joe Staff - 19.04.2011

@Alby Fire: That's not what he's asking, he wants to know if it's possible to increment an SQL row without needlessly retrieving the info, costing time and bandwidth
Maybe this will help http://answers.yahoo.com/question/in...6162630AA9NkQB


Re: Simple SQL question - Alby Fire - 19.04.2011

Quote:
Originally Posted by SilentHuntR
Посмотреть сообщение
@Alby Fire: That's not what he's asking, he wants to know if it's possible to increment an SQL row without needlessly retrieving the info, costing time and bandwidth
Oh, seeing this "$money" I firstly thought he always used SQL in PHP, and he wanted to know hot to use it in pawn..
Nevermind!


Re: Simple SQL question - kLx - 19.04.2011

Quote:
Originally Posted by ******
Посмотреть сообщение
You would need a SELECT to get the old version and a SET to store the new value after adding the new bit to the old store.
Actually, you don't need to select it,
pawn Код:
UPDATE `players` SET `money`=`money`+%d
, that's it.


Re: Simple SQL question - KaleOtter - 19.04.2011

Thanks for your respond youall.
And about the pawn thing.
I know alot about pawn but not that much about php and sql.
And what I'm asking is how I can use something like += in a qeury (in php).
So actualy it has nothing to do with PAWN. So maybe also the wrong board.
But I thought maybe somebody know a easy way to do this in php so I wouldn't register on another forum about PHP for just a small question like this.

But ye like ****** said, I gues i should first get the data then edit it and then update it again
But i will try that link first SilentHuntR