H
henrik.johansson
I need help with a query that sorts out unmatched fields from two
tables. I've tried with an union query but it matches my duplicates as
well... I want my duplicates to be unmatched. Any suggestions?
Table 1
Date Account Amount
2007-02-13 123 300
2007-02-13 456 500
2007-02-13 111 100
2007-02-13 111 100 ( I want this duplicate to be unmatched)
2007-02-14 222 200
2007-02-14 555 650
Table 2
Date Account Amount
2007-02-13 123 300
2007-02-13 456 450
2007-02-13 111 100
2007-02-13 333 700
2007-02-14 222 200
2007-02-14 444 250
SELECT T1.Account, T1.Amount, T2.Account, T1.Amount
FROM T1 LEFT JOIN T2 ON (T1.Account=T2.Account) AND
(T1.Amount=T2.Amount)
UNION SELECT T1.Account, T1.Amount, T2.Account, T1.Amount
FROM T2 LEFT JOIN T1 ON (T1.Account=T2.Account) AND
(T1.Amount=T2.Amount);
tables. I've tried with an union query but it matches my duplicates as
well... I want my duplicates to be unmatched. Any suggestions?
Table 1
Date Account Amount
2007-02-13 123 300
2007-02-13 456 500
2007-02-13 111 100
2007-02-13 111 100 ( I want this duplicate to be unmatched)
2007-02-14 222 200
2007-02-14 555 650
Table 2
Date Account Amount
2007-02-13 123 300
2007-02-13 456 450
2007-02-13 111 100
2007-02-13 333 700
2007-02-14 222 200
2007-02-14 444 250
SELECT T1.Account, T1.Amount, T2.Account, T1.Amount
FROM T1 LEFT JOIN T2 ON (T1.Account=T2.Account) AND
(T1.Amount=T2.Amount)
UNION SELECT T1.Account, T1.Amount, T2.Account, T1.Amount
FROM T2 LEFT JOIN T1 ON (T1.Account=T2.Account) AND
(T1.Amount=T2.Amount);