Jump to content


Photo

mySQL Operator Question [SOLVED]


  • Please log in to reply
2 replies to this topic

#1 jmaccs64

jmaccs64
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 17 September 2006 - 06:04 PM

How would I have SQL subtract 1 from a certain field where a match is found?



#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 17 September 2006 - 09:11 PM

UPDATE yourTable SET yourField = IF( yourField = 'yourValue', yourField-1, yourField )
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 jmaccs64

jmaccs64
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 18 September 2006 - 03:44 AM

Your the best Fenway!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users