473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Non matching records with many to many relationship

3
Access Ver 2003 and Windows XP.

I have one table with 3 columns:

CustomerNo
Type
Name

The type can have 6 different values. One of them let's call it Z needs to be used check it exists in one of the other Types for that customer number.

What I have done is to create 2 queries, to split the records. One where the Type is Z the other where the type is not Z.

I have then created a query with and inner join on CustomerNo which calls the 2 queries (which are basically views I guess).

This is where I am stuck. Because for a given CustomerNo with Type Z, there can be 2 names.

My results come back with multiple mis-matches most of which are pairs that actually match the result next to it.

i.e.

CustNo Type Name CustNo Type Name
1 Z N1 1 X N2
1 Z N2 1 Y N1

Cheers in advance

Mr Rusty SQL :)
Any ideas on this? Does it make sense what I am trying to do?
Nov 28 '08 #1
4 1476
ChipR
1,287 Expert 1GB
What exactly do you want to see from your query? There must be a simpler way to get the results you want than to create 2 queries to divide the records, then just join them back together.
Nov 28 '08 #2
szhjcn
3
Hi,

What I want to be able to see is for each account number there is one or more type Z's Each type has a name associated with it.

I need to check if the names in against the type Z's exist in the other types for that account, if not list the account.

There are 5 other possible types.

As I said my SQL is rusty and probably was never upto expert level.

Thanks again for your offer to help.
Dec 1 '08 #3
szhjcn
3
I guess for me the issue is that there can be 2 entries/names with type Z for a given account.
Dec 1 '08 #4
ChipR
1,287 Expert 1GB
Maybe something like:
SELECT AccountNumber, Name FROM MyTable as Table1 WHERE Type = 'Z' AND NOT EXISTS (SELECT Name, AccountNumber FROM MyTable as Table2 WHERE Table1.AccountNumber = Table2.AccountNumber AND Table1.Name = Table2.Name AND Table2.Type <> 'Z')

That would give you the name and account number from Z type accounts where there is no record with the same account number and name but a type other than Z.

If this isn't quite what you want, let me know exactly what the fields in your table are and we'll come up with something.
Dec 1 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
6
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from...
6
by: davegb | last post by:
I've searched here and in the help screens, but I can't find the answer to a very simple question. How do I create a specific link between 2 records in 2 different tables? I know how to use the...
3
by: klufkee | last post by:
Hi all, I have two tables that are related to each other. One has 30K records while the other has 500. I ran a 'Without Matching' query to find records in the larger table that didn't have a...
1
by: amywolfie | last post by:
I am trying to prevent employees from referencing their own loans. Here's the VBA Code: Dim strApplicant As String strApplicant = "dbo_snapshot_loan_app.applcnt_first_nm & "" &...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
9
by: warrior2009 | last post by:
I have 2 lists (unlinked and unrelated), where one can be called the parent and the other the child with one to many relationship between parent-child. The child table is really big, over a million...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.