View Single Post
Old 11-16-2012, 01:19 AM   PM User | #8
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
And of course you can increment a field as shown there.

You can do a lot more than that:
Code:
UPDATE sometable SET field1 = field1 + 1 + IF(field2 > 3, 7, -12 )
WHERE id = 9102 AND field1 < 1000000
and so on and so on.

Heck, you can even "tack on" to text fields:
Code:
UPDATE sometable SET ticks = CONCAT( ticks,'*') WHERE id = 1817
That would make the ticks field grow by one "*" every time the UPDATE is executed.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
Custard7A (11-16-2012)