[Mysql] Modify an existing value
#1

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

`money` = money + 50

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

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

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

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

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

Without ' ' ?

I mean without 'Money + %d' ?
Reply
#8

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)