PDA

View Full Version : MySQL Question


NitroSimSev
07-22-2006, 10:46 PM
Ok I need to run a query on my USER table, what I am looking to do is if a user has a 1 in the donator field I need their donate field updated to by 1. Any ideas how I can do this. I know it should be easy.

louis_chypher
07-24-2006, 12:17 PM
Ok I need to run a query on my USER table, what I am looking to do is if a user has a 1 in the donator field I need their donate field updated to by 1. Any ideas how I can do this. I know it should be easy.

To increment the donate field count by one if the donate field count is already a 1:

UPDATE table_name SET table_field=(1 + table_fieldname) WHERE table_filed=1;

table_name is the name of the dB.
table_field is the name of the field you are updating.