SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Increment by 1

  1. #1
    SitePoint Enthusiast Bloobird's Avatar
    Join Date
    Jan 2005
    Location
    Wales UK
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Increment by 1

    I am trying to write an SQL statement that increments a quantity by one everytime it is executed.

    So far I have

    UPDATE products SET quantity = ++1 WHERE product_id = 1;

    The ++1 bit is what I thought it would be, but its not.
    Does anyone know how I can alter the above statement to increment by 1??

    This is going to be used in a inventory control system.

    Thanks in advance

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    699
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    UPDATE products SET quantity = quantity+1 WHERE product_id = 1

  3. #3
    SitePoint Enthusiast Bloobird's Avatar
    Join Date
    Jan 2005
    Location
    Wales UK
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks very much! Thats just what I was looking for!!


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
  •