473,542 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1736
>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(blobote xt,
'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(blobote xt,
'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
2040
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 check whether the size and colour fields match what's in the db, if they do then you've already added this item with the same colours and size so,...
2
9474
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 variable is $case. I can't make that piece of code working fine. Anyone can help please ? my $str = "Hello World!"; my $pattern "hello"; my $case =...
4
1996
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 datagrid isn't going to work). On this page, people can update a variet of records. On submit, I want to then go in and update all of the records. ...
2
2937
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
1968
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 names") and then displays all records with company names in a datagridview. Once the information has been binded to the datagridview control, I allow...
7
13334
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. I want to match records in an Access query that will match the fields based on the last 4 characters, which fortunately, are unique in both tables....
10
2218
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 an array of checkboxes, but my update loop is not working. Here is my code: /*---------This retrieves the records -------------*/ if($row_md) {...
4
2105
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
1706
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 points. These records are imported from a txt file, and never manually entered. Currently there are no forms at all. The first problem is that the...
0
7392
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7721
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5867
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5246
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3376
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1798
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.