"Adam DeVita" <[email protected]> wrote
in message
news:[email protected]
> Suppose you have a field that time stamps the date each company's data
> was entered.
>
> Unfortunately some records in old2.db have newer contact information,
> while others are older than in old1.db.
>
> Since companies sometimes change their address the one with the latest
> 'date_Entered' should be the one left in the merged database.
Try something like this:
select * from old1 x where not exists (
select 1 from old1 y
where x.company = y.company and x.date_entered < y.date_entered)
and not exists (
select 1 from old2 z
where x.company = z.company and x.date_entered < z.date_entered);
insert into new
select * from old2 x where not exists (
select 1 from old1 y
where x.company = y.company and x.date_entered < y.date_entered)
and not exists (
select 1 from old2 z
where x.company = z.company and x.date_entered < z.date_entered);
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users