Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2007
    Posts
    34

    Unanswered: UPDATE using wildcard

    Hi,

    Is there a way to use wildcards to update this recordset? I've got a column with 'madison county, cook county, dupage county' and i'd like to change it to
    'madison, cook, dupage'

    I can make each change individually, but is there a simpler way?

    update physician
    SET physician_practice_County1 = 'Madison'
    where physician_practice_County1= 'Madison County'

    I tried the following:

    update physician
    SET physician_practice_County1 = '%'
    where physician_practice_County1= '% County'

    all help appreciated.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    why not just remove all occurrences of the word 'county' from the column, would that work?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Feb 2007
    Posts
    34
    Like this?

    I tried this in a small test and it seems to work. Can you take a look and tell me if you see any errors? Thanks.

    UPDATE physician
    SET physician_practice_County1 =(REPLACE(physician_practice_County1 ,'County',''))

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    looks great

    i would write it without the parentheses around the function
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    Quote Originally Posted by hconnor
    Like this?

    I tried this in a small test and it seems to work. Can you take a look and tell me if you see any errors? Thanks.

    UPDATE physician
    SET physician_practice_County1 =(REPLACE(physician_practice_County1 ,'County',''))
    Pointing out the obvious: a WHERE clause would be a good idea here.

Posting Permissions

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