SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Minimizing Queries

    I'm trying to update a table column, all I want to do is add 1 to the numeric value it holds. How can I do this without first selecting its current contents? This would cut my number of queries in half.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2000
    Location
    Allentown PA
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A relative update

    UPDATE table SET column=column+1 WHERE whatever='something';

  3. #3
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try something like:

    UPDATE tableName SET fieldName = fieldName + 1 WHERE...

    edited : sorry... must have added a reply at same time as Ed Sullivan (great minds think alike, fools seldom differ!!!)

  4. #4
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    k thanks!

    Thank You

  5. #5
    SitePoint Addict lveale's Avatar
    Join Date
    Jun 2001
    Location
    Dublin
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no worries!


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
  •