Hi to all,
I have two tables with the same fields:
Table1: Name, Date, Value
Table2: Name, Date, Value
They have some combinations of the fields Name and Date that are the same, example:
Table1: Jonh, 2010-05-01, 2
Table2: Jonh, 2010-05-01, 1
I wanted to insert in Table1 the combinations of the fields Name and Date that are not in Table1 (or create a new table with this). I'm doing this with a "Not In" clause but it takes a long long time. My Query is as follow:
Is there a better solution for this? Any help is much appreciated.
Thanks in advance.
I have two tables with the same fields:
Table1: Name, Date, Value
Table2: Name, Date, Value
They have some combinations of the fields Name and Date that are the same, example:
Table1: Jonh, 2010-05-01, 2
Table2: Jonh, 2010-05-01, 1
I wanted to insert in Table1 the combinations of the fields Name and Date that are not in Table1 (or create a new table with this). I'm doing this with a "Not In" clause but it takes a long long time. My Query is as follow:
Code:
SELECT * INTO NewTable FROM (SELECT * FROM Table1 WHERE Name & Date NOT IN (SELECT Fund & Date FROM Table2) Union ALL SELECT * FROM Table2) ORDER BY Name, Date;
Is there a better solution for this? Any help is much appreciated.
Thanks in advance.