Solved

Move Field values in same table

Posted on 2007-03-22
5
149 Views
Last Modified: 2013-12-16
I have a table with 3 fields, field1, field2 and field3. I need to write an update query that moves field2 to field1 AND if field3 is entered, move field3 to field1 (replacing value just moved from field2). How can I accomplish this by using coldfusion?
0
Comment
Question by:Errol Farro
  • 3
  • 2
5 Comments
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 125 total points
ID: 18771697
?

update yourtable
 set field1 = coalesce(field3,field2)
where ...
0
 

Author Comment

by:Errol Farro
ID: 18772092
Thanks man, you are indeed a genius. I never heard of the coalesce function.
0
 

Author Comment

by:Errol Farro
ID: 18773486
Question: Is there a way to consider 0 as a not-null expression? It works fine when the value is Null but not when value is 0. Please advice.
0
 

Author Comment

by:Errol Farro
ID: 18773500
Sorry for the Typo:

Question: Is there a way to consider 0 also as a null expression? It works fine when the value is Null but not when value is 0. Please advice.
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 18775745
update yourtable
 set field1 = coalesce(nullif(field3,0),field2)
where ...


nullif ( a,b) returns null if a and b are equal...  else a
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Updating a table from a temp table 4 36
How to join on ID, with prefix? 15 58
SQL Server 2012 rs - Field1 and Field2 add 1 to Total 4 18
sql server concatenate fields 10 35
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question