Can someone tell me what is wrong with my update query?
I am trying to update 2 different records with the same CategoryID, but different PartsID and collectionID. I think I am on the right track with a loop, but I am not sure whether I have the right type of loop. Secondly, the records are updating, but they are inserting LISTS, which I don't want. How can I avoid the LIST?
So, record 1 is a yellow postcard. I need to update the collections that the postcard belongs to. I really need help on this because I have similar programs. But if I can't get this, then my other programs will fail when I need to update. ANY HELP IS GREATLY APPRECIATED.
Also, could someone recommend a site on looping logic?
Here's the query:
<cfif IsDefined ("Form.FieldNames")>
<cfloop index="i" list="#Form.FieldNames#" delimiters=",">
<cfif LEFT (i,4) IS "UPD_">
<cfset selectpartsID=RemoveChars(i,1,4)>
<cfset selectpartsID=#Evaluate(selectpartsID)#>
</cfif>
<cfquery name="Update" datasource="#request.dsn#">
UPDATE TESTmuseum_parts
SET
collectionID='#collectionID#'
WHERE PartsID=#selectpartsID#
</cfquery>
</cfloop>
I am trying to update 2 different records with the same CategoryID, but different PartsID and collectionID. I think I am on the right track with a loop, but I am not sure whether I have the right type of loop. Secondly, the records are updating, but they are inserting LISTS, which I don't want. How can I avoid the LIST?
So, record 1 is a yellow postcard. I need to update the collections that the postcard belongs to. I really need help on this because I have similar programs. But if I can't get this, then my other programs will fail when I need to update. ANY HELP IS GREATLY APPRECIATED.
Also, could someone recommend a site on looping logic?
Here's the query:
<cfif IsDefined ("Form.FieldNames")>
<cfloop index="i" list="#Form.FieldNames#" delimiters=",">
<cfif LEFT (i,4) IS "UPD_">
<cfset selectpartsID=RemoveChars(i,1,4)>
<cfset selectpartsID=#Evaluate(selectpartsID)#>
</cfif>
<cfquery name="Update" datasource="#request.dsn#">
UPDATE TESTmuseum_parts
SET
collectionID='#collectionID#'
WHERE PartsID=#selectpartsID#
</cfquery>
</cfloop>