View previous topic :: View next topic
|
Author |
Message |
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
Hi,
i want to update a certain part of column .
eg :
there is column NAME (char(20)) .
i want to change first letter of column NAME from 'a' to 'b' .
so i want to know can i use substring command with update .
Thanks in advance,
-Kapil . |
|
Back to top |
|
|
Gurmeet
New User
Joined: 22 Feb 2006 Posts: 46 Location: Pune
|
|
|
|
Kapil,
User this query,
UPDATE Table_name SET name = 'b' || SUBSTR(name,2)
WHERE name = 'abc';
~Gurmeet |
|
Back to top |
|
|
krish_mrt
New User
Joined: 15 Apr 2005 Posts: 12 Location: Chennai
|
|
|
|
Hi,
Try this update
Code: |
update table_name
set name = 'b'||substr(name,2)
where name like 'a%'
|
|
|
Back to top |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
Thanks Buddy .
this seems to be perfect
-Kapil . |
|
Back to top |
|
|
rexzone1
New User
Joined: 16 Dec 2006 Posts: 14 Location: Halifax, Canada
|
|
|
|
Hi,
I need to do the same operation(Update particular part of a column) on a numeric field.
Could you please suggest me a way if there is any (without using a program).
Thanks. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Possibly, if what you need to do can be accomplished by some calculaton. . .
Otherwise, write the code. . . |
|
Back to top |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
Well, it would be better if you can provide exact requirement details.
-Thanks,
-Kapil. |
|
Back to top |
|
|
Vivek_Vasudevamurthy
New User
Joined: 19 Sep 2008 Posts: 9 Location: Bangalore,Karnataka
|
|
|
|
Hi friends,
if i want change any letter in center or set of letters how it will work
For a example
"ABCDEF"
now i want to change "CDE" to "XYZ"
==============================
User this query,
UPDATE Table_name SET name = 'b' || SUBSTR(name,2)
WHERE name = 'abc';
in this query what 2 stands for |
|
Back to top |
|
|
ashok_uddaraju
New User
Joined: 21 Feb 2007 Posts: 72 Location: US
|
|
|
|
Let me put in some idea on how the substr command works.
when i say SET name = 'b' || SUBSTR(name,2)
then the the letter 'b' in the first position (i+1) which is 1+1 in this case will be considered.
If you want to change the first two characters it should be
'bc' || SUBSTR(name,3) ----- i+2
One thing i ma not clear is what can be done when we require a substring to slect from some where in the middle.
I assue there should be one more parameter in the SUBSTR command in that case.
Can some body suggest on this? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Something to keep in mind is that many/most data manipulation requirements will not be met by some simple sql query. . . |
|
Back to top |
|
|
|