Home » SQL & PL/SQL » SQL & PL/SQL » Update command
Update command [message #623973] Wed, 17 September 2014 00:38 Go to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
I have table Test

Columns are s_from, distance_km, distance

I have to update distance_km column by value of distance column.

Please suggest me.
Re: Update command [message #623975 is a reply to message #623973] Wed, 17 September 2014 00:43 Go to previous messageGo to next message
Mayur Shinde
Messages: 60
Registered: August 2014
Location: Pune, Maharashtra
Member
Table structure is like :
s_from	distance_km	distance
--------------------------------------
B	  10	          50
B	  20	
J	  5	          70
J	  7	          20
N	  10	          70
N	  15	          60
B	  20	
J		          70
N		


[EDITED by LF: applied [code] tags to preserve formatting]

[Updated on: Wed, 17 September 2014 01:23] by Moderator

Report message to a moderator

Re: Update command [message #623978 is a reply to message #623975] Wed, 17 September 2014 01:25 Go to previous messageGo to next message
Littlefoot
Messages: 21807
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:

I have to update distance_km column by value of distance column.


What does the second message's information mean? Is it current situation, or is it desired output? I *guess* - based on quoted statement - that it is what you currently have. In that case:
update test set
  distance_km = distance;

Re: Update command [message #624109 is a reply to message #623978] Wed, 17 September 2014 16:07 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
just curious. Why do you have two columns with the exact same information? And if distance is null, do you want to replace the value in distance_km with a null or leave the original value?

[Updated on: Wed, 17 September 2014 16:09]

Report message to a moderator

Previous Topic: Performance Issue [Merged]
Next Topic: Can an {interval quantifier} contain a REGEXP_INSTR expression
Goto Forum:
  


Current Time: Tue Apr 16 12:11:02 CDT 2024