Solved

Select Query from 2 Tables

Posted on 2008-06-19
2
213 Views
Last Modified: 2011-10-19
Need to select records that match and then those that don't match from the 2 tables (See attached)
Would like to compare Table A statid to Table B statid and if those don't match, try to match on Table A id2 with TableB Id2 (or vice versa..whatever works).
 I have to account for NULLS and blanks in the statid & id2 fields. I have thousands of recs in each file.
Thank you!
AandBFiles.xls
0
Comment
Question by:lbarnett419
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 21826801
those that do match:
SELECT * FROM tableA a JOIN tableB b on a.statid = b.statid

those in A but not in B:
SELECT a.* FROM tableA a LEFT JOIN tableB b on a.statid = b.statid WHERE b.statid IS NULL

those in B but not in A:
SELECT a.* FROM tableB B LEFT JOIN tableA a on a.statid = b.statid WHERE a.statid IS NULL
0
 

Author Closing Comment

by:lbarnett419
ID: 31468982
Thanks!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question