On 9/6/07, Andre du Plessis <[EMAIL PROTECTED]> wrote:

> Im importing data
>
> The data has a unique value, call it MD5 for now that could be a unique
> value for the data.
>
>
>
> Each record that gets imported is converted to MD5, a lookup is done on
> the table for that MD5,
>
> if found it must leave it alone, if not found it must insert a new
> record...


<<snip>>

A SQL approach to this would be to force a left inner join creating a result
set which would indicate which records currently exist/does not exist in the
primary table.  So in the result set, if both columns have values, then the
record exists in the primary table and needs to be updated, if the column
from the primary table is null, then it doesn't exist and must be inserted.
To determine which records need to be deleted, force a right outer join, and
use similar logic to determine which records need to be deleted.

Unfortunately the SQL dialects I learned were prior to SQL-92, and my
examples use the database engine proprietary syntax to indicate forced
inner/outer joins, so I can't give you an example.  I'm going to post
another message asking what the correct syntax would be in SQL-92 terms.

Reply via email to