SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Add instead of update in MySQL

    Is there a way to use update to add a number to a database field instead of replacing it.

    For example currently when I update a field containing a 5 with the number 6 it just replaces the 5 with a 6.

    I'd really like it to just add the new number to the existing one - in this case making 11.

    Any one know how?

    Cheer

    Dave

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,234
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    UPDATE TABLE_NAME SET FIELD_NAME = FIELD_NAME + NEW_VALUE WHERE CRITERIA_IS_MET


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •