Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace column data with another column 1

Status
Not open for further replies.

dkemas

Programmer
Mar 22, 2012
70
GB
I have a database with a 'date' data type where some of the fields are 0000-00-00.

I need to run a SQL command that will find all date that are 0000-00-00 and replace with a date that is in another field.

The column name with some instances of 0000-00-00 is date_finished
The column name with the value to replace this is duedate

I am kind of there

update mytable set date_finished = replace(date_finished,'0000-00-00','*duedate column*');

How do I specify to replace the date_finished 0000-00-00 with the duedate field in each row?

Thanks
 
Something like:

Code:
[b][COLOR=#0000FF]update[/color][/b] mytable [b][COLOR=#0000FF]set[/color][/b] date_finished [COLOR=#990000]=[/color] due_date [b][COLOR=#0000FF]where[/color][/b] date_finished [COLOR=#990000]=[/color] [COLOR=#FF0000]"0000-00-00"[/color]

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thanks Phil, I was skirting around that solution but just a whisker away :)
 
Glad I could help.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top