Move Field values in same table

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?
Errol FarroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LowfatspreadCommented:
?

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Errol FarroAuthor Commented:
Thanks man, you are indeed a genius. I never heard of the coalesce function.
0
Errol FarroAuthor Commented:
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
Errol FarroAuthor Commented:
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
LowfatspreadCommented:
update yourtable
 set field1 = coalesce(nullif(field3,0),field2)
where ...


nullif ( a,b) returns null if a and b are equal...  else a
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.