View Full Version : Returning Non-Duplicate Items


jmcbrayer
10-30-2009, 10:31 AM
Hello all,

Basically what I am trying to accomplish is to take two tables (EDR_HISTORY & IN_STA) and compare two columns that have identifying numbers assigned to them. The returned results must also have other criteria specified but you will see that in the SQL code I post.

Now, what I need is to pull everything from the EDR_HISTORY report that does not have a corresponding ID in the IN_STA table. i.e. EDR_HISTORY has IDs 1, 2, 3, 4, 5, 6,7 and IN_STA has IDs 1,2,3,5,6,7...I need a query that will return '4' along with the other specified criteria of course.

The SQL I have for this query is:

SELECT [EDR_HISTORY].*
FROM [EDR_HISTORY] LEFT JOIN [IN_STA]
ON [EDR_HISTORY].[S/S-LOAN-NO]=[IN_STA].[OCN LN]
AND ((([EDR_ HISTORY].[1ST-DEF-ACT-CODE])="43") AND (([EDR_HISTORY].[1ST-DEF-ACT-CODE-DT])>=[beg date] And (([EDR_HISTORY].[1ST-DEF-ACT-CODE-DT])<=[end date])
WHERE (([IN_STA].[OCN_LN]) Is Null));

Trying to save this results in a "Syntax Error in JOIN Operation" when I try to save it.

Any help would be appreciated.

Thanks,
James

ByteMyzer
10-30-2009, 12:09 PM
First off, your SQL syntax needs some cleanup. Try:
SELECT [EDR_HISTORY].*
FROM [EDR_HISTORY] LEFT JOIN [IN_STA]
ON [EDR_HISTORY].[S/S-LOAN-NO]=[IN_STA].[OCN LN]
WHERE [EDR_ HISTORY].[1ST-DEF-ACT-CODE]="43"
AND [EDR_HISTORY].[1ST-DEF-ACT-CODE-DT]>=[beg date]
AND [EDR_HISTORY].[1ST-DEF-ACT-CODE-DT]<=[end date]
AND [IN_STA].[OCN_LN] Is Null;