Update multiple records from a list

Posted on 2014-08-14
Last Modified: 2014-08-14
I have a text field and some checkboxes. When the form is submitted the check boxes create a list. The field is called "selected". So, After the form is submitted I have a 2 fields, one is a list of numbers(selected)  like this 3,7,9,10 and a value from the text box "car",

The values from "Selected" are the IDs from each record i would like to update. So, if the boxes 5,6,7 were checked I want to update records with ID 5,6,7 with the value from the text box.

Could someone assist with this? I'd like to avoid having a query in a loop. Thank you.
Question by:earwig75
    LVL 39

    Accepted Solution

    Just use....    in ()

    update theTable
       set aColumn = 'Something'
    where primaryKey_id in (#form.IDlist#)

    Author Comment

    Thank you, I don't know why I forgot about "IN". I did have to do it this way though: IN (<cfqueryparam value = "#form.SELECTED#" list="true" CFSQLType = "CF_SQL_BIGINT">)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Suggested Solutions

    This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
    CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 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

    9 Experts available now in Live!

    Get 1:1 Help Now