comparing different data source tables
I need to find records in one table that are not in another but the other table is in a different dsn. I've tried this so many ways, as a query of a query, referencing an array, as a loop and I'm still not getting the correct results. I can't do a join that I'm aware of as these are different datasources. The best bet I thought would be a query of a query or a loop. This is a backup table so the column names are the same. I've tried using #quotedvaluelist( )# in the query as well but there are over 4,000 records and it's timing out.
For my loop attempt the code looked like this but it ignores the id that is not in the other table. I was hoping the cfif statement would pull out those that did not match but it seems to skip these. Any suggestions would be appreciated. Thanks Wendy
<cfquery datasource="#dsn#" name="q1">
select ID from table1
WHERE (STATUS = 'A' or
STATUS = 'L' or
STATUS = 'P' or
STATUS = 'S')
ORDER BY convert(numeric,ID)
</cfquery>
<cfloop query="q1">
<cfquery datasource="#dsn2#" name="q2">
select ID, STATUS
from table2
WHERE ID = '#trim(q1ID)#'
</cfquery>
<cfif #q2.recordcount# eq "0">
<cfoutput>#q2.ID# #q2.STATUS#</cfoutput>
</cfif>
</cfloop>
