SA-MP Forums Archive
[Mysql] Modify an existing value - 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)
+--- Thread: [Mysql] Modify an existing value (/showthread.php?tid=495260)



[Mysql] Modify an existing value - anou1 - 16.02.2014

Hi,

Код:
 mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Money` = 'MODIFY THIS VALUE'  WHERE `Username` = '%e'", nom);
What I want to do is add a value to a preivous one.
If the money value is X, I want to get this value then add Y.

Example: Money value: 1000
I want to add to this +50.

How could I do please ?
Get the initial value then update it ?


Sorry if I'm not clear, but if you need more explanations just ask


Re: [Mysql] Modify an existing value - trukker1998 - 16.02.2014

`money` = money + 50

New code:
Код:
mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Money` = 'Money + 50'  WHERE `Username` = '%e'", nom);



Re: [Mysql] Modify an existing value - anou1 - 16.02.2014

Thank you, so It will work for a sql query ?


Re: [Mysql] Modify an existing value - trukker1998 - 16.02.2014

Quote:
Originally Posted by anou1
Посмотреть сообщение
Thank you, so It will work for a sql query ?
It worked for me in PHP, so it should work in every SQL excuter.
And if the example doesn't work remove the '' tags in the query.


Re: [Mysql] Modify an existing value - anou1 - 16.02.2014

Okay, thank you, I will try


Is this still okay ?:

mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Money` = 'Money + '%d' ' WHERE `Username` = '%e'", somme, nom);


Re: [Mysql] Modify an existing value - trukker1998 - 16.02.2014

Quote:
Originally Posted by anou1
Посмотреть сообщение
Okay, thank you, I will try


Is this still okay ?:

mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Money` = 'Money + '%d' ' WHERE `Username` = '%e'", somme, nom);
No, try this:
Код:
mysql_format(mysql, query, sizeof(query),"UPDATE `joueurs` SET `Money` = Money + %d  WHERE `Username` = '%e'", somme, nom);



Re: [Mysql] Modify an existing value - anou1 - 16.02.2014

Without ' ' ?

I mean without 'Money + %d' ?


Re: [Mysql] Modify an existing value - trukker1998 - 16.02.2014

Quote:
Originally Posted by anou1
Посмотреть сообщение
Without ' ' ?

I mean without 'Money + %d' ?
Try this.. you will see if it works .