Partially updating records based on pattern match

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SomeDude

    Partially updating records based on pattern match

    Lo group,

    I would like to know if it is possible to a (string) replace on
    existing records based on a given pattern.

    Let's say I have a table containing the following records (strings):
    Windows/98
    Windows/98/Registry
    Windows/2000
    Windows/2000/Registry

    Is there an SQL method for scanning all records in the
    table for the pattern "Windows/98" and then, when a match is made, replace
    only the "Windows/98" part of the string with "Windows/2003"?

    I am having a hard time figuring this out so any help would be
    more than welcome.

    SomeDude.



  • Gordon Burditt

    #2
    Re: Partially updating records based on pattern match

    >I would like to know if it is possible to a (string) replace on[color=blue]
    >existing records based on a given pattern.
    >
    >Let's say I have a table containing the following records (strings):
    >Windows/98
    >Windows/98/Registry
    >Windows/2000
    >Windows/2000/Registry
    >
    >Is there an SQL method for scanning all records in the
    >table for the pattern "Windows/98" and then, when a match is made, replace
    >only the "Windows/98" part of the string with "Windows/2003"?[/color]

    MySQL allows something like:

    update tablename set blobotext = replace(blobote xt,
    'Windows/98', 'Windows/2003');

    If there are several instances of 'Windows/98' in blobotext, all
    of them are replaced.

    Gordon L. Burditt

    Comment

    • SomeDude

      #3
      Re: Partially updating records based on pattern match

      On Wed, 05 Oct 2005 01:06:58 +0000, Gordon Burditt wrote:
      [color=blue][color=green]
      >>I would like to know if it is possible to a (string) replace on
      >>existing records based on a given pattern.
      >>
      >>Let's say I have a table containing the following records (strings):
      >>Windows/98
      >>Windows/98/Registry
      >>Windows/2000
      >>Windows/2000/Registry
      >>
      >>Is there an SQL method for scanning all records in the
      >>table for the pattern "Windows/98" and then, when a match is made, replace
      >>only the "Windows/98" part of the string with "Windows/2003"?[/color]
      >
      > MySQL allows something like:
      >
      > update tablename set blobotext = replace(blobote xt,
      > 'Windows/98', 'Windows/2003');
      >
      > If there are several instances of 'Windows/98' in blobotext, all
      > of them are replaced.
      >
      > Gordon L. Burditt[/color]

      Woohoo!

      Gordon, your solution works like a charm!

      You have really helped me out here, thanks a lot.

      SomeDude

      Comment

      Working...