SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to skip update record ?

    I have a joined update query as below...

    UPDATE items,month SET items.price=month.price
    WHERE items.id=month.id;



    if price value has '?' in it then I just want to skip updating the record. How do I do it ?

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    OH, USA
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    UPDATE items,month
    SET items.price=month.price
    WHERE items.id=month.id
    and month.price<>'?';

  3. #3
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gk53 View Post
    UPDATE items,month
    SET items.price=month.price
    WHERE items.id=month.id
    and month.price<>'?';

    No. This will not work.

    because Price field value could be like this ...

    430-29?8-9 //don't update because it has '?'
    4?-0-29?8-9 //don't update because it has '?'
    ?-29?8-? //don't update because it has '?'
    127-65-34 //update it because it does not have '?'


    In simple words if the price field value has a "?" in it then just skip this record ...don't update.

    How this can be done ?

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    OH, USA
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in this case. In you original post you said...

    UPDATE items,month
    SET items.price=month.price
    WHERE items.id=month.id
    and month.price not like '%?%';

  5. #5
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    I try to always approach a non-select statement as a select statement at first, and then convert it over once you have ensured your going to be affecting the rows that you want.


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
  •