Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2006, 05:15 AM
Authorized User
 
Join Date: Jul 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to lawsoncobol
Default SQL INNER JOIN problem

The two table contains same data , but there could be missing rows

Row - Number- Row number
Company - Number - which is same for all the data
Loc - Text - changes for some records
EmpNo - Number - changes for some records
Key - unique key would be combination of set of some fields given below
Company + Loc + Empno+ StartDate
Table1
Row, Company, Loc, EmpNo, EmpName, BenType, Plan, StartDate, stopDate
1 4321 MN 1000 a X A date1
2 4321 MN 1000 a X B date2 date3
3 4321 MN 1000 a X B date5
( 3- Missing record in Table 2)
4 4321 SC 1010 b Y C date4

Table2
Row, Company, Loc, EmpNo, EmpName, BenType, Plan, StartDate, stopDate
1 4321 MN 1000 a X A date1
2 4321 MN 1000 a X B date2 date3
3 4321 SC 1010 b Y C date4

Note that Row is different

What could be the SQL query to retrive the data from table 1 which is present in table1 and missing in table 2

Thanks and Regards
Lawson, COBOL
__________________
Thanks and Regards
Lawson, COBOL
 
Old August 17th, 2006, 02:29 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Use the Query Wizard and create a "Find Unmatched" query. This will build it for you automatically. It will find those records in Table 1 that have no corresponding record in Table 2, based on some field value (in your case, Row).

This is what the SQL looks like (from Northwind):
(I searched for Customers who do not have a matching name in Employees)

SELECT Customers.CustomerID, Customers.CompanyName
FROM Customers LEFT JOIN Employees ON Customers.ContactName = Employees.LastName
WHERE (((Employees.LastName) Is Null));



mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
My SQL, ASP, and Inner Join Knuckles2003 Classic ASP Databases 0 October 31st, 2005 02:24 AM
SQL join problem mattastic SQL Language 2 May 26th, 2005 08:27 AM
SQL Join mattastic SQL Server 2000 9 April 21st, 2005 10:27 AM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM
SQL Inner Join Problem tp194 Classic ASP Databases 2 July 8th, 2003 09:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.