Erik, This is pretty difficult to troubleshoot without looking at the data. I suspect it is your loop and initial query and not your insert code.
-mk Mark A. Kruger, CFG, MCSE (402) 408-3733 ext 105 www.cfwebtools.com www.coldfusionmuse.com www.necfug.com -----Original Message----- From: erik tom [mailto:[EMAIL PROTECTED] Sent: Friday, April 25, 2008 11:37 AM To: CF-Talk Subject: ColdFusion query question I have problem updating the DB table. I have 3 text boxes which has specific id. if the value of that boxes changed i wanto compare to DB and update the option for that id and only for that id . Instead it updates for all ids <cfif isDefined("btnOption")> <cfloop index="i" from="1" to="#ListLen(form.opt)#"> <cfset variables.this=ListGetAt(form.opt,i)> <cfloop query="getOptions"> <cfset option2=#getOptions.id#> <cfquery name="getOptions2" datasource="cfelsunrise" dbtype="odbc" > select * from questionOptions where id in (#option2#) and options ='#variables.this#' </cfquery> <cfif getOptions2.recordcount eq 0> <cfquery name="qryOptionSave2" datasource="cfelsunrise" dbtype="odbc"> update questionOptions set options='#variables.this#' where id='#option2#' and surveyID=#surveyID# and questionID=#questionID# </cfquery> </cfif> </cfloop> </cfloop> <!--- <cflocation url="addRemoveQuestion.cfm?surveyID=#surveyID#" addtoken="no">---> </cfif> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304238 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4