473,785 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ 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_Per formance.*, Select_List.Cat egory
FROM ((Select_List_P erformance LEFT JOIN Categories ON
Select_List_Per formance.Mornin gstar_Category =
Categories.Morn ingstar_Categor y) LEFT JOIN Select_List ON
Categories.Morn ingstar_Categor y = Select_List.Cat egory) LEFT JOIN
Sorted_Template ON Select_List.Tic ker = Sorted_Template .Ticker
WHERE (((Select_List_ Performance.Cat _Bnch) Like 'c*') AND
((Categories.Se lect_List_Group ing) Like 'Large*') AND
(((Sorted_Templ ate.Ticker) Is Null)))
ORDER BY Select_List.Cat egory;

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 4534
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_Per formance ON
Categories.Morn ingstar_Categor y =
Select_List_Per formance.Mornin gstar_Category) INNER JOIN (Select_List LEFT
JOIN Sorted_Template ON Select_List.Tic ker = Sorted_Template .Ticker) ON
Select_List_Per formance.Ticker = Select_List.Tic ker
Nov 12 '05 #3

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

Similar topics

2
3708
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" table I want to know which region. I'm lost. Can someone help? Here is my code.
0
1439
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 created manually without using the UMQ Wizard. The problem/question, however, involves using these tables in an UMQ Wizard. At the point in the wizard where it asks for "What piece of information is in both tables?" and it lists the fields from the 2...
5
2884
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 print it off and ring round and hurry them up a bit. I have my quote table which has the supplier ID, Site ID and an ID for each quote.(I enter each quote and specify which supplier and site it relates to. I've tried an unmatched query but can't...
2
1642
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 create a macro that will go into each of the 200 databases, run an identical "unmatched query" to find any records that might be in one of the copies of the "tblCodebook". There is a shared primary key in the "tblCodebook" which is a StoryID and...
1
1995
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 create a macro that will go into each of the 200 databases, run an identical "unmatched query" to find any records that might be in one of the copies of the "tblCodebook". There is a shared primary key in the "tblCodebook" which is a StoryID and...
2
1954
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 "Drop Offs" out of the Hard table. my sql for the query I am running follows: 1st Query - pulls the data from the live tables.
0
1952
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 both 2003 and 2000 formats. It's not my access databases because the wizard works correctly over the network using other people's Access software. It is with every Access mdb database I have tried. I have checked every setting imaginable but...
1
1589
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 Legalfile but not in Cases. In order to club the conversion and join in one query I has the criteria for LegalFile.CaseID set to Int(). With this setup if I run the query it gives me all entries that are common in LegalFile and Cases. I tried setting...
1
4683
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 INQS INQ INQSO BASIC BALQU
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4055
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 we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.