1

in vb.net how would you loop through database1 to check that all records in database2 exist in Database1 and the other way areound if a record exist in database1 and doesnt exist in database2 then delete it from database1. so database2 is my reference

how can i do this using queries, also does it have to include nested looping?

note that the records are not in the same order

Thanks

4

1 に答える 1

1

このクエリは、テーブルのローカル バージョンにないアタッチされたテーブルのすべての行を返します。

SELECT * FROM attachedTable 
WHERE col1 NOT IN( SELECT lt.col1 FROM localTable as lt)

これは逆のことを行い、リモート テーブルで一致しないローカル テーブルのすべての行を返します。

SELECT * FROM localTable 
WHERE col1 NOT IN( SELECT rt.col1 FROM attachedTable As rt)
于 2012-08-02T01:51:32.120 に答える