Skip to main content
November 7, 2007
Answered

Search from List contents...

  • November 7, 2007
  • 2 replies
  • 319 views
I wish to have a list of product ids that I can select the desired info from the database on each and it all be part of the same query. How do I do this for a list of ids?

normally it's what I have below, so how can I amend this to take a numeric list of products and select all for each id in the list?

Thanks!
    This topic has been closed for replies.
    Correct answer cf_dev2
    WHERE ID IN ( <cfqueryparam list="true" value="#arguments.listOfIDs#" ... > )

    2 replies

    November 7, 2007
    Great, that's what I needed, sorry a little new to CF. Thanks!
    Inspiring
    November 8, 2007
    You're welcome. Just remember to verify the list is not empty or the query will bomb. Another option is to append a non-existent record id like 0 to ensure the list is never empty

    <cfqueryparam list="true" value ="#listAppend(arguments.listOfIDs, 0)#" ....>
    cf_dev2Correct answer
    Inspiring
    November 7, 2007
    WHERE ID IN ( <cfqueryparam list="true" value="#arguments.listOfIDs#" ... > )