Home » SQL & PL/SQL » SQL & PL/SQL » Replacing a particular charater in the data being displayed
icon10.gif  Replacing a particular charater in the data being displayed [message #255241] Tue, 31 July 2007 02:34 Go to next message
vamsikgummadi
Messages: 62
Registered: April 2006
Location: United States, MI
Member
Hello friends,
Hope all of you are having a nice time.
Again I came up with a new problem. I need your help and suggestion to solve this problem.

The problem is as follows:

I have a table car with fields SNo, CarMake, Milage just as shown below:
Sno CarMake Milage
1 Maruthi 20000km
2 Opel 10000Km
3 Benz 45000Km
4 BMW 1500km

A clear observation reveals that under the column Milage in some rows 'Km' was used and in some rows 'km' is used.
Now I want to replace 'km' to 'Km' i.e., I want to replace particular charater of the data that was present in Database table.

How can I attain a solution for this problem.
Please suggest me how to solve this problem. It will also be helpful if you can forward code snippets for solving this problem.

Hope to get back from you at the earliest.
Vamsi K Gummadi.
Re: Replacing a particular charater in the data being displayed [message #255243 is a reply to message #255241] Tue, 31 July 2007 02:41 Go to previous messageGo to next message
yoonus.it@gmail.com
Messages: 109
Registered: June 2007
Location: kuwait
Senior Member
You dont remeber update command?

you can do it with simple update command..

Thanx
regards
Re: Replacing a particular charater in the data being displayed [message #255244 is a reply to message #255241] Tue, 31 July 2007 02:41 Go to previous messageGo to next message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Did you envisage to use the "replace" function?

Regards
Michel
Re: Replacing a particular charater in the data being displayed [message #255256 is a reply to message #255241] Tue, 31 July 2007 03:53 Go to previous messageGo to next message
vamsikgummadi
Messages: 62
Registered: April 2006
Location: United States, MI
Member
Dear Friends,

I have already tried the Update and Replace options that you have suggested but I am not completly successful in implimentation. I have also tried to do the same in SQL server also but all went in vain.
I would also send the code snippets of my trails if required. So I need Search and replace functionality.Please forward the code snippets if possible.

Thanking you,
Vamsi K Gummadi.


Re: Replacing a particular charater in the data being displayed [message #255266 is a reply to message #255256] Tue, 31 July 2007 04:27 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
vamsikgummadi wrote on Tue, 31 July 2007 10:53
I have already tried the Update and Replace options that you have suggested...
So you tried a
SELECT REPLACE(milage,'km','Km') 
FROM  yourtable;
without success?

What went wrong?

MHE
Re: Replacing a particular charater in the data being displayed [message #255296 is a reply to message #255241] Tue, 31 July 2007 05:31 Go to previous messageGo to next message
vamsikgummadi
Messages: 62
Registered: April 2006
Location: United States, MI
Member
Hello all,

Thank you for the support and suggestions.
Actually I am trying like this:
SELECT REPLACE( 'MS SQL Server - SQL Server', 'Server', 'Server 2005' ) from DB1;

but I am unable to recognize what is actually happening. The problem is I have been confused in identifying 'Original-String', 'Search-String' and 'Replace-String'.
I don't know why I have gone wrong. Thank you for the reply at the right time otherwise I would have wasted a lot of time in thinking what went wrong. So, now I think I need to go through the basics once again.

Thank you all for your support and special thanks to Maaher.

Cheers,
Vamsi K Gummadi.
Re: Replacing a particular charater in the data being displayed [message #255953 is a reply to message #255241] Thu, 02 August 2007 09:39 Go to previous messageGo to next message
rsreddy28
Messages: 295
Registered: May 2007
Senior Member
Hi,

update car set mileage=replace(mileage,'km','KM');

This should update all the records at one go.

Hope this helps.lemme know anything req'd.


Regards,

Raj

[Updated on: Thu, 02 August 2007 09:40]

Report message to a moderator

Re: Replacing a particular charater in the data being displayed [message #255992 is a reply to message #255953] Thu, 02 August 2007 12:49 Go to previous messageGo to next message
Michel Cadot
Messages: 64122
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
lemme know anything req'd.

Use correct english.

Regards
Michel
Re: Replacing a particular charater in the data being displayed [message #255996 is a reply to message #255296] Thu, 02 August 2007 12:52 Go to previous messageGo to next message
joy_division
Messages: 4641
Registered: February 2005
Location: East Coast USA
Senior Member
vamsikgummadi wrote on Tue, 31 July 2007 06:31

Actually I am trying like this:
SELECT REPLACE( 'MS SQL Server - SQL Server', 'Server', 'Server 2005' ) from DB1;

but I am unable to recognize what is actually happening. The problem is I have been confused in identifying 'Original-String', 'Search-String' and 'Replace-String'.




It is so very easy to search google for the replace function, but for some reason you didn't try that, so click on this link:

http://www.techonthenet.com/oracle/functions/replace.php
icon14.gif  Re: Replacing a particular charater in the data being displayed [message #256095 is a reply to message #255953] Fri, 03 August 2007 00:58 Go to previous message
vamsikgummadi
Messages: 62
Registered: April 2006
Location: United States, MI
Member
Hello friends,
I have already solved this problem.Sorry, for not intimating the same to you. I have used the code forwarded by Maaher and I have also written a procedure for finding and replacing a particular string with the help received from all of you. Thank you all for the support provided.
Regards,
Vamsi K Gummadi. Laughing
Previous Topic: SQL STATEMENT FOR CALCULATION
Next Topic: case statment
Goto Forum:
  


Current Time: Wed Dec 07 05:05:05 CST 2016

Total time taken to generate the page: 0.08474 seconds