Update sql table using coldfusion query and loop

I have a table that I need to clear values first then update it with correct data. It needs to happen 3 times. For some reason it's only happening once.
Please see code below:

<cfquery name="updateFeaturedCourse" datasource="#application.dsName#" username="#application.dsUserName#" password="#application.dsPassword#">
                        UPDATE courses
                        SET featuredcourse = 'N', featuredcourseordernumber = 0
                        WHERE featuredcourse = 'Y'
                <cfloop from="1" to="3" index="ThisRow">
                        <!--- extract each value --->
                  UPDATE courses
                  SET featuredcourse = 'Y', featuredcourseordernumber = '#Evaluate('form.hcf_#ThisRow#')#'
                  WHERE courseid ='#Evaluate('form.hf_#ThisRow#')#'
                        </cfloop>
            </cfquery>
                  <cflocation url="set_featured_courses.cfm?aid=m" addtoken="no">
asaworkerAsked:
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.

rob_lorentzCommented:
as a point of style i try to limit myself to 1 SQL statement per cfquery

So, first of all i would split your 2 updates into 2 cfqueries.

                        <!--- extract each value --->

<cfquery >
    UPDATE courses
    SET featuredcourse = 'N', featuredcourseordernumber = 0
    WHERE featuredcourse = 'Y'
</cfquery>
<cfloop from="1" to="3" index="ThisRow">
    <cfquery>
        UPDATE courses
        SET featuredcourse = 'Y', featuredcourseordernumber = '#Evaluate('form.hcf_#ThisRow#')#'
         WHERE courseid ='#Evaluate('form.hf_#ThisRow#')#'
    </cfquery>
</cfloop>

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
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 Servers

From novice to tech pro — start learning today.