Simple SQL question
#1

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?
Reply
#2

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);
Reply
#3

@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
Reply
#4

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!
Reply
#5

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.
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)