473,396 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1730
>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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Roy Adams | last post by:
Hi everyone I'm trying to build a shopping cart app using a db the part I'm stuck on is the fact that, if someone adds a product that they have previously added to the cart. I've got it set up to...
2
by: Pierre | last post by:
Hello, I would like to write a regexp that can be either case sensitive or that can ignore the case based on a variable (value would be either 'i' or ''). For instance in the below code the...
4
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a...
2
by: Andrew Robert | last post by:
I have two Perl expressions If windows: perl -ple "s/()/sprintf(q#%%%2X#, ord $1)/ge" somefile.txt If posix perl -ple 's/()/sprintf("%%%2X", ord $1)/ge' somefile.txt
5
by: JimmyKoolPantz | last post by:
Situation: I am writing a program that opens up a data file (file ext .dbf), imports the information into a dataset. The program also, searches through the dataset for key words ("company...
7
by: Petepinca | last post by:
I have 2 Access tables. One has a field with a 4 character product id. Example data: "3210". The other table has the same product id's for matching records BUT has leading characters: "RD3210", etc....
10
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created...
4
by: mosesdinakaran | last post by:
Can any one explain how the rule is applied for the following Regular expression $Str = 'the red king'; $Pattern = '/((red|white) (king|queen))/'; preg_match($Pattern,$Str,$Val); Result:
2
tdw
by: tdw | last post by:
Hi all, I have several ideas on how to do this, but am having difficulty putting the ideas together and figuring out the most efficient way to do this. I have a database of survey coordinate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.