Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:45:11+00:00 2026-05-31T17:45:11+00:00

I have been trying to update a table in MySQL 5.0 with Coldfusion MX

  • 0

I have been trying to update a table in MySQL 5.0 with Coldfusion MX 7. But the query only updates/adds the first records and does not update/add the other 60,000 records.

<cfquery name="count" datasource="voyager">
SELECT 
        PATRON.PATRON_ID, 
        PATRON.HISTORICAL_CHARGES, 
        PATRON.HISTORICAL_BOOKINGS, 
        PATRON.HISTORICAL_DISTRIBUTIONS, 
        PATRON.HISTORICAL_SHORT_LOANS, 
        PATRON.HISTORICAL_CHARGES_UB, 
        PATRON.HISTORICAL_REQUESTS_UB
FROM PATRON
</cfquery>


<cfquery name="update" datasource="patrons">
    <cfoutput>
    REPLACE INTO patrondailyusecounttotals (PATRON_ID, HISTORICAL_CHARGES)
    VALUES ('#count.PATRON_ID#', '#count.HISTORICAL_CHARGES#')
    </cfoutput>
</cfquery>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:45:12+00:00Added an answer on May 31, 2026 at 5:45 pm

    You’ll need to use a loop:

    <cfquery name="count" datasource="voyager">
      SELECT 
        PATRON.PATRON_ID, 
        PATRON.HISTORICAL_CHARGES, 
        PATRON.HISTORICAL_BOOKINGS, 
        PATRON.HISTORICAL_DISTRIBUTIONS, 
        PATRON.HISTORICAL_SHORT_LOANS, 
        PATRON.HISTORICAL_CHARGES_UB, 
        PATRON.HISTORICAL_REQUESTS_UB
      FROM 
        PATRON
    </cfquery>
    
    <cfloop query="count">
      <cfquery name="update" datasource="patrons">
        REPLACE INTO patrondailyusecounttotals (PATRON_ID, HISTORICAL_CHARGES)
        VALUES (
          <cfqueryparam value="#PATRON_ID#" cfsqltype="CF_SQL_VARCHAR">, 
          <cfqueryparam value="#HISTORICAL_CHARGES#" cfsqltype="CF_SQL_VARCHAR">
        )
      </cfoutput>
    </cfloop>
    

    Note that using <cfqueryparam> is the recommended approach here. It will speed up the “inner query” by a lot, since with each loop iteration after the first one only the parameter values are transmitted to the server (instead of transmitting the full SQL code every time).


    EDIT

    The original version of the answer recommended the following, but obviously that’s is not enough in a situation involving separate database servers.

    <cfquery name="update" datasource="patrons">
      REPLACE INTO 
         patrondailyusecounttotals (PATRON.PATRON_ID, HISTORICAL_CHARGES)
      SELECT 
         PATRON_ID, HISTORICAL_CHARGES
      FROM 
         PATRON
    </cfquery>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to display a MySQL table for some time and I
I have been trying to convert a complex SELECT query to an UPDATE query,
I have been trying to use OleDbDataAdapter to update a DataTable but got confused
I'm trying to update some properties with KVC. The properties have been synthesized. This
I am relatively new to MySQL and PHP and I have been trying to
I have been trying to get this query to work for the longest and
I am trying to update cached_name column of callog.calls table in android,but getting sql
I'm using Visual C# Studio 2010 express and have been trying to batch update
I have been trying for hours but couldn't figure out why it doesn't show
Have have been trying to make a validator for my xml files. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.