#1
  1. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    what i would like to do is something like:

    UPDATE table
    SET field = 1
    WHERE field IN(1,2,3,4,5)

    UPDATE table
    SET field = 0
    WHERE field NOT IN(1,2,3,4,5)

    except i want to do this in 1 query instead of 2, is this possible?

    the reason i want to do this in only 1 query is that i don't want to take the chance that the first query will execute and then the second query fails, this would totally screw up the data

    any solutions would be greatly appreciated
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    update table set field=if(field IN(1,2,3,4,5),1,0);
  4. #3
  5. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    thanks rod, you just made my day!

    [This message has been edited by RyanP (edited September 30, 2000).]

Similar Threads

  1. Form doesn't update db values
    By zippu in forum PHP Development
    Replies: 7
    Last Post: February 14th, 2004, 02:05 PM
  2. Query to choose different values in field
    By angrypanda in forum MySQL Help
    Replies: 2
    Last Post: January 30th, 2004, 04:48 PM
  3. Run report after update query
    By friendly_state in forum Database Management
    Replies: 1
    Last Post: January 26th, 2004, 01:24 PM
  4. How to update a webpage for a long running DB query
    By kevdavis in forum HTML Programming
    Replies: 2
    Last Post: January 20th, 2004, 04:21 PM
  5. Array query using <SELECT> form field
    By u230503 in forum ASP Programming
    Replies: 1
    Last Post: January 19th, 2004, 04:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo