Page 1 of 1

Mysql Question!

Posted: Wed Apr 20, 2005 12:33 pm
by zolo44
Quick Question,

I need to select, add and update a mysql table all in one query. Does anybody have any suggestions?

For example. I need to know the number of a field in a table, once i get the number i need to increament/decreament it by a given number, then i need to update that field.

I need to do it all in one shot cause i have a script that increaments it at least 5 times a second. Now, i know i can do seperate calls but not sure if i would be getting the right amount that percise second.

Not sure if i'm making sence, but can anybody help? I've checked mysql.com and couldn't find anything that could help me.... or i just didn't know what to look for.


thanks

Posted: Wed Apr 20, 2005 1:07 pm
by pickle
Something like this should work:

Code: Select all

UPDATE
  some_table
SET
  changing_field = changing_field + 1
WHERE
  id = 'some_id_value'

Posted: Wed Apr 20, 2005 3:44 pm
by zolo44
Ah man, was that all... I didn't think you could do that.

Thanks for your help... I feel kinda dumb... :)