473,951 Members | 43,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating a specific column ( Special case )

539 Contributor
I have a table, where it composed of several columns, but i am concerning only on a specific column with datatype varchar under that db table...

Now, for example:

column: links
values:

http://localhost/asdf/asdf.php
http://localhost/
http://localhost/12312/adfdf.php
http://localhost/ghierew/adfd.html


Now, i would like to update the said column such that it only replace the
'http://localhost/' to some value or let us say an existing website rootlink 'http://www.google.com. ph/'

that will result into

http://www.google.com.ph/asdf/asdf.php
http://www.google.com.ph/
http://www.google.com.ph/12312/adfdf.php
http://www.google.com.ph/ghierew/adfd.html

I expect from this db table to have millions of row, therefore i doubt to implement my idea of replacing them one by one at a time because this db table is just acting like a temporary storage that will be truncated by the time the control system will demand a new temporary storage... and it takes little time to process... Thread-timing bug will arise

I believe that the MySQL Server will process this just in time.

Is it possible to do it on just a query? or queries? Java is the front-end
Dec 28 '09 #1
2 2203
Atli
5,058 Recognized Expert Expert
Hey.

The query to update a table in such a way is simple enough:
Expand|Select|Wrap|Line Numbers
  1. UPDATE `tbl`
  2. SET `links` = REPLACE(`links`, 'http://localhost/', 'http://www.google.com.ph/');
I'm not sure how that will work with you temporary truncation scenario, but if your table gets truncated/re-created often, and you need this to happen for every row that get's inserted, you could try creating a Trigger that does this automatically each time a INSERT statement is issued.
Expand|Select|Wrap|Line Numbers
  1. CREATE TRIGGER `tbl_links_insert` BEFORE INSERT ON `tbl`
  2. FOR EACH ROW
  3. BEGIN
  4.     NEW.links = REPLACE(NEW.links, 'http://localhost/', 'http://www.google.com.ph/');
  5. END;
This could create a performance bottle-neck though, so you should look out for that.
Dec 28 '09 #2
sukatoa
539 Contributor
Thank you for your reply Atli :)
Dec 30 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

53
3739
by: Oliver Fromme | last post by:
Hi, I'm trying to write a Python function that parses an expression and builds a function tree from it (recursively). During parsing, lambda functions for the the terms and sub-expressions are constructed on the fly. Now my problem is lazy evaluation. Or at least I think it is. :-)
1
1957
by: Yasaswi Pulavarti | last post by:
Is it possible to order by specific values in a column. For example a column may contain values like N, N1, N2, S, S1, S2, R, T. I want to order by in such a way that all the records with N, N1, or N2 in that specific column will show up on the top. All the records with S1, S2 values will show up next and finally all records with R and T values in that specific column will show up. Please give me the select syntax. Sincerely, Yasaswi...
1
3350
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently overwhelmed by useless examples across the web on how to make "dynamic crosstab reports" without myself having a basic understanding about how to retrieve and assign recordsources, etc., from fields in a query to fields in the report. I see all these...
3
13124
by: Tc | last post by:
Hi, I was curious, I am thinking of writing an application that loads a dataset from a database that resides on a server. The question I have is this, if multiple copies of the app will be running at once will there be problems with data updates? The reason I ask is I'm thinking like this: User1 launches the app and the dataset is created from the data in the DB.
1
11093
by: BStorm | last post by:
Does anyone know the best way to update a DataTable row column using specific values for a multipart primary key? For example, updating an OrderAmt column in an OrderDetail table where the primary key consists of an OrderNo and DetailSeqNo?
4
2038
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. Normally, I'd make each form element include a runat: server and then declare it in my codebhind so I...
1
4371
by: sekisho | last post by:
I'm dynamically adding a column of labels and a column of text boxes to a panel on a webform, based on data returned from an SQL query, which the user builds by selecting options from a few dropdowns and hitting the 'Search' button. The first column returned is a user name and is added to the panel as a label, the second is a number and is added to the label as the text property of a textbox, so the user can update it. When the...
0
968
by: astro | last post by:
I have a non-updatable column in a SQL:-Server view that represents a 1-to {0,1} relation with a child table. I want the end-user to be able to change this value. This view is generated with the following SQL code: create view dbo.v_leads_person AS SELECT p.personID,
33
3411
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range of 20 steps) On the admin page the steps are listed, in "order" order and the user can create new steps and assign an order and all is well. The problem may come in using a renumber function which should take the steps in their current order...
0
10173
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9994
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11607
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11199
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11377
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10703
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9907
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7445
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4968
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.