By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,705 Members | 1,852 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,705 IT Pros & Developers. It's quick & easy.

how to create sql code not duplicate Record

P: 1
Hi!
Please help me!
How to create sql code ..
Records from two tables do not match
Thank You!
Table 1
Per1 Per2 Per3
A1 B1 C1
A1 B1 C2
A1 B1 C3
A1 B1 C4
A2 B1 C1
A2 B1 C2
A2 B1 C3
A2 B2 C4
A2 B2 C1
A2 B2 C2
A2 B2 C3

Table 2
Per1 Per2 Per3
A1 B1 C3
A2 B1 C2
A2 B2 C1

Results
Per1 Per2 Per3
A1 B1 C1
A1 B1 C2
A1 B1 C4
A2 B1 C1
A2 B1 C3
A2 B2 C4
A2 B2 C2
A2 B2 C3
Jun 14 '12 #1
Share this Question
Share on Google+
1 Reply


100+
P: 759
This work on your test data but do more tests to be sure.

Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT Table1.Per1, Table1.Per2, Table1.Per3
  2. FROM Table1 LEFT JOIN Table2 ON (Table1.Per3 = Table2.Per3) AND (Table1.Per2 = Table2.Per2) AND (Table1.Per1 = Table2.Per1)
  3. WHERE (((([Table1]![Per1]=[Table2]![Per1]) And ([Table1]![Per2]=[Table2]![Per2]) And ([Table1]![Per3]=[Table2]![Per3])) Is Null))
  4. ORDER BY Table1.Per1, Table1.Per2, Table1.Per3;
Jun 14 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.