Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

SQL query - find Table 1, Table 2 common records

Dear Gurus
Microsoft Access has an 'unmatched query' wizard whose SQL code looks like this:
SELECT TABLE_2.COMPANY_NAME
FROM TABLE_2 LEFT JOIN DB_ALL_1 ON TABLE_2.COMPANY_NAME = TABLE1.COMPANY_NAME
WHERE (((TABLE1.COMPANY_NAME) Is Null));

How do I modify the code so that what is returned are Table_1 records that also appear in Table_2?
0
BrianBeck
Asked:
BrianBeck
  • 2
  • 2
1 Solution
 
Jai STech ArchCommented:
SELECT TABLE_1.COMPANY_NAME
FROM TABLE_1 LEFT JOIN DB_ALL_1 ON TABLE_1.COMPANY_NAME = TABLE2.COMPANY_NAME
WHERE (((TABLE1.COMPANY_NAME) Is Null));
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
SELECT TABLE_2.COMPANY_NAME
FROM TABLE_2 INNER JOIN DB_ALL_1 ON TABLE_2.COMPANY_NAME = TABLE1.COMPANY_NAME
0
 
Jai STech ArchCommented:
SELECT TABLE_1.COMPANY_NAME
FROM TABLE_1 LEFT JOIN DB_ALL_1 ON TABLE_1.COMPANY_NAME = TABLE2.COMPANY_NAME
0
 
BrianBeckAuthor Commented:
Hi jaiganeshsrinivasan:
Thanks, and firstly, apologies for my typo.  The text 'DB_ALL_1' should read 'TABLE_1'.
Now, I'm confused. Aside from swapping "1" and "2" how is your code different to mine above?

OK, I think the answer looks like:
SELECT TABLE_2.COMPANY_NAME
FROM TABLE_2 LEFT JOIN TABLE_1 ON TABLE_2.COMPANY_NAME = TABLE1.COMPANY_NAME
WHERE (((TABLE1.COMPANY_NAME = TABLE_2.COMPANY_NAME )));
0
 
BrianBeckAuthor Commented:
Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now