2021年2月10日星期三

trying to use mysql update on insert

I have a data loading from an excel file where i am adding all the checks to check for the uploaded file and insert data accordingly, till this point everything seems to be working good.

Now i am using the folowing to insert into a query

<cfquery datasource="dsn">          INSERT INTO tblcustomers(FirstName,LastName,address,emailaddress,status)           VALUES(<cfqueryparam cfsqltype="varchar" value="#queryData.firstname[currentRow]#">,              <cfqueryparam cfsqltype="varchar" value="#queryData.lastname[currentRow]#">,              <cfqueryparam cfsqltype="varchar" value="#queryData.address[currentRow]#">,              <cfqueryparam cfsqltype="varchar" value="#queryData.emailaddress[currentRow]#">,              <cfqueryparam cfsqltype="integer" value="#queryData.status[currentRow]#">)          </cfquery>  

my focus here is, i can reupload the same file with some minor changes and rather than inserting the data, i should update the existing data if exists and insert if nits new

the unique key is the email here

so if person removes the emailadress from excel and replace with something else, i am bit lost here should i delete that record or insert a new one because email was changed

https://stackoverflow.com/questions/66148194/trying-to-use-mysql-update-on-insert February 11, 2021 at 11:05AM

没有评论:

发表评论