View previous topic :: View next topic |
Author |
Message |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Wed Jul 12, 2006 3:48 am Post subject: Query for removing Space and Unstring |
|
|
Hi,
I have a db2 table called as "Emptable" with 5 fields.
rollno - 10
Name - 25
halltino - 10
adress - 25
pincode - 10
....
My requirement is:
If there is a space in Halltino, remove the part after space.
Ex:
1)if Halltino='1234 56789' remove the value after space.then it will be halltino='1234'
2)if Halltino='1 3456789' remove the value after space.then it will be halltino='1'
3)if Halltino='1 3 56789' remove the value after space.then it will be halltino='1'
Could any one pls. tell me the query to get this.
Regards
nadh |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
Jaya Beginner

Joined: 02 Sep 2005 Posts: 77 Topics: 10 Location: Cincinnati
|
Posted: Wed Jul 12, 2006 5:18 am Post subject: |
|
|
Nadh,
Please try this...
Code: |
UPDATE Emptable
SET halltino=SUBSTR(halltino,1,POSSTR(halltino,' ') - 1)
WHERE ...; |
Thanks,
Jaya. _________________ "Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein |
|
Back to top |
|
 |
Jaya Beginner

Joined: 02 Sep 2005 Posts: 77 Topics: 10 Location: Cincinnati
|
Posted: Wed Jul 12, 2006 5:24 am Post subject: |
|
|
oops!!...The solution is already posted. I forgot to click the submit button earlier.
Jaya.. _________________ "Great spirits have always encountered violent opposition from mediocre minds."
-Albert Einstein |
|
Back to top |
|
 |
|
|