473,473 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Unmatched Query with Multiple Tables

I want to extract some records that are common to three tables, but not
contained in the fourth. Following what I have see in the archives and also
trying the unmatched records query wizard, if I only use one of those three
tables and use a LEFT JOIN to the fourth and set the target field in the
fourth table to null, I get the unmatched records.

However, if I link the three tables together and then want to exclude
records in the fourth table, it does not work.

What I have looks like this:

Table 1--->Table2--->Tabel3--->Table4 (is null)

Here is the code
SELECT DISTINCT Select_List_Performance.*, Select_List.Category
FROM ((Select_List_Performance LEFT JOIN Categories ON
Select_List_Performance.Morningstar_Category =
Categories.Morningstar_Category) LEFT JOIN Select_List ON
Categories.Morningstar_Category = Select_List.Category) LEFT JOIN
Sorted_Template ON Select_List.Ticker = Sorted_Template.Ticker
WHERE (((Select_List_Performance.Cat_Bnch) Like 'c*') AND
((Categories.Select_List_Grouping) Like 'Large*') AND
(((Sorted_Template.Ticker) Is Null)))
ORDER BY Select_List.Category;

If I were to split this up into two queries, one to create a new table with
the common records of the first three tables and the second to link this to
the fourth table to get unmatched records, it works. So I am guessing that
this might be a case of not using parentheses correctly and that a subquery
would work. But I've tried that without success. Any idea as to what I am
doing wrong?

Thanks
Alan
Nov 12 '05 #1
2 4513
Hi,

Colleyville Alan <ae***********@nospam.comcast.net> wrote:
I want to extract some records that are common to three tables, but not
contained in the fourth.


I think you should use an inner join for the first three joins and an
outer join only for the last one. An outer join (i.e left or right join)
returns all records matching the key and those with a null value in the
key field. You seem to have null values in a key field for one of the
first three joins thus those records are returned, the results of the
following joins then do not matter.

HTH,
Chris
Nov 12 '05 #2
"Christoph Sticksel" <sp***************@gmx.net> wrote in message
news:c8**********@news2.rz.uni-karlsruhe.de...
Hi,

Colleyville Alan <ae***********@nospam.comcast.net> wrote:
I want to extract some records that are common to three tables, but not
contained in the fourth.


I think you should use an inner join for the first three joins and an
outer join only for the last one. An outer join (i.e left or right join)
returns all records matching the key and those with a null value in the
key field. You seem to have null values in a key field for one of the
first three joins thus those records are returned, the results of the
following joins then do not matter.

HTH,
Chris


I tried that earlier and by itself it did not seem to help. But I then
tried it and also changed the order of the tables and then it worked.
Having "Categories" as the first table seems to do the trick.

FROM (Categories INNER JOIN Select_List_Performance ON
Categories.Morningstar_Category =
Select_List_Performance.Morningstar_Category) INNER JOIN (Select_List LEFT
JOIN Sorted_Template ON Select_List.Ticker = Sorted_Template.Ticker) ON
Select_List_Performance.Ticker = Select_List.Ticker
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sal cifone | last post by:
Hello, I am trying to use access vba instead of running an unmatched query. I want to compare two tables and if there is a new sales office in "Commissions" table that is not in the "Conversion"...
0
by: Ellen Ricca | last post by:
I have an Access db with several ODBC linked ORACLE tables. These tables have multiple-field PK's. The tables work just fine in many diff types of queries including unmatched queries that are...
5
by: themastertaylor | last post by:
I've got a system to manage various quotes for building materials for a number of sites. i want a query to produce a report that shows me who HASN'T quoted for which sites. basically so i can...
2
by: rfranzl | last post by:
Hello, I need some help, I have about 200 databases that are copies of an original database that has a similiar table in all of the databases, called "tblCodebook". What I am trying to do is to...
1
by: rfranzl | last post by:
Hello, I need some help, I have about 200 databases that are copies of an original database that has a similiar table in all of the databases, called "tblCodebook". What I am trying to do is to...
2
by: scolivas | last post by:
Is there a way to automate this process? I have a query that finds the "Drop Offs" by doing an unmatch query against the hard table and the live table. I want to automatically pull these...
0
by: Sharon V | last post by:
This is driving me crazy - my unmatched query wizard will not display field names for any tables I choose. All my other query wizards work properly. I am running Access 2003. I have tried using...
1
by: AccessHunter | last post by:
Please Help.... I have a query with 2 tables, LegalFile and Cases. LegalFile has the field CaseID(Number Field) and Cases has CaseNbr(Text Field). I am trying to find entries that are in...
1
by: Tlou5831 | last post by:
I am attempting to compare 2 tables in my DB and find unmatched criteria. There are 2 different fields in each database that need to be compared. Tbl_AppUsers Role Settings INQ ...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.