469,950 Members | 2,360 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

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.

Oct 4 '05 #1
2 1641
>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"?


MySQL allows something like:

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

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

Gordon L. Burditt
Oct 5 '05 #2
On Wed, 05 Oct 2005 01:06:58 +0000, Gordon Burditt wrote:
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"?


MySQL allows something like:

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

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

Gordon L. Burditt


Woohoo!

Gordon, your solution works like a charm!

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

SomeDude

Oct 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Roy Adams | last post: by
4 posts views Thread by Darrel | last post: by
2 posts views Thread by Andrew Robert | last post: by
5 posts views Thread by JimmyKoolPantz | last post: by
10 posts views Thread by chimambo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.