?
Solved

Query Two Tables

Posted on 2012-09-01
3
Medium Priority
?
942 Views
Last Modified: 2012-09-01
I have a database that has two tables.  One table contains the details of a shop order, ie... T-Shirt Size, T-Shirt Color, Quantities of each.
Each item is stored individually but the entire order has a reference number.

The second Table contains the shipping and postage info for the entire order and is associated by the reference number.

How do I query both tables at the same time to see if both tables have the same reference numbers and if table two does not have the reference number and associated info it will print out the reference number from table one?

So, in a nut shell... query both tables and compare if each have a specific reference number and give me a list of entries in table one that do not have a matching reference number in table 2.
0
Comment
Question by:rgranlund
  • 2
3 Comments
 
LVL 20

Accepted Solution

by:
thehagman earned 2000 total points
ID: 38357456
select distinct(table1.referencenumber) from table1 left join  table2 on table1.referencnumber=table2.referencenumber where table2.referencenumber is NULL
0
 
LVL 7

Author Comment

by:rgranlund
ID: 38357469
Will that work if there is no reference number in table two at all?
0
 
LVL 7

Author Comment

by:rgranlund
ID: 38357537
@ thehagman   Thanks !!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

864 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