I am trying to compare the data in a datebase table with the data in a CSV file. Only the first column is being used/compared in the CSV file to/with a column in the DB table. Whatever is listed in the CSV file column and is not equal to that which is in the database table must be displayed to the browser. Here is some code:
<cfset DepartmentCodes = QueryNew('DepartmentCode')>
<cfset strFilePath = (CFFILE.ServerDirectory & "\" & CFFILE.ServerFile) />
<!--- get and read the CSV-TXT file --->
<cffile action="read" file="#strFilePath#" variable="csvfile">
<!---loop through the CSV-TXT file on line breaks and insert into database --->
<cfloop index="index" list="#csvfile#" delimiters="#chr(10)##chr(13)#">
<cfset CSVcolumn = '#listgetAt('#index#',1)#'>
<cfquery name="GetCodes" datasource="#serverDNS#">
WHERE Deleted = 0
AND Code <> '#CSVcolumn#'
<cfif GetCodes.Recordcount GT 0>
<cfset NewRow = queryAddRow(DepartmentCodes)>
<cfset tempCodes = querySetCell(DepartmentCodes, 'DepartmentCode', #CSVcolumn#)>
This is returning all the Data in the CSV column, all i need is the data not in the database table which are listed in the CSV file.
Direct email firstname.lastname@example.org