Solved

Move Field values in same table

Posted on 2007-03-22
5
148 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to find the last word in a string in SQLITE 14 70
PL/SQL LOOP CURSOR 3 58
Oracle Pivot Question 8 45
What logic to build in order to get a weekly reminder 9 42
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
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.
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now