473,387 Members | 1,722 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,387 software developers and data experts.

Unmatched Query

Hello and please help
I have two tables: TYPES and NAME_TYPE.
Expand|Select|Wrap|Line Numbers
  1. TYPES:
  2. type
  3. A
  4. B
  5. C
  6. D
  7. E
  8.  
  9. NAME_TYPE
  10. name     surname      type
  11. John     Doe     C
  12. John     Doe     B
  13. Jack     Daniels     D
  14. Will     Smith     C
  15. Brad     Pitt     A
  16. George     Dumb     E
  17.  
and I want to display all types that don't belong to some person.
For example if person is George Dumb, i want query return result:
A
B
C
D
or if person is John Doe, query result need to be:
A
D
E

How should i do that ? What is the right query?
Apr 7 '07 #1
6 3183
Hello and please help
I have two tables: TYPES and NAME_TYPE.
Expand|Select|Wrap|Line Numbers
  1. TYPES:
  2. type
  3. A
  4. B
  5. C
  6. D
  7. E
  8.  
  9. NAME_TYPE
  10. name     surname      type
  11. John     Doe     C
  12. John     Doe     B
  13. Jack     Daniels     D
  14. Will     Smith     C
  15. Brad     Pitt     A
  16. George     Dumb     E
  17.  
and I want to display all types that don't belong to some person.
For example if person is George Dumb, i want query return result:
A
B
C
D
or if person is John Doe, query result need to be:
A
D
E

How should i do that ? What is the right query?
Hmm...I'm not a real "Access Expert", but that would probably have to do with Relationships.
Apr 8 '07 #2
nico5038
3,080 Expert 2GB
This can be solved using the IN() predicate in the WHERE clause.
Inside the IN() you can use a subquery, so in your case try:
select ... from tblX a
WHERE Not a.Type IN(select Type from tblX b where b.Name=a.Name)

The a and b are qualifiers for the tables to keep the fields "unique" for Access.

Getting the idea ?

Nic;o)
Apr 8 '07 #3
NeoPa
32,556 Expert Mod 16PB
The "Find Unmatched Query Wizard" will create something for you. It works by using a LEFT JOIN and including Is Null on the linked to field in the WHERE clause.
Apr 12 '07 #4
I try with IN operator. This is right query:

Expand|Select|Wrap|Line Numbers
  1. SELECT type from TYPES WHERE type not in
  2. (SELECT type FROM name_type WHERE name="John")
thank you.
Apr 13 '07 #5
nico5038
3,080 Expert 2GB
Looks OK to me, but the nice thing of queries is the fact that you can run them to prove they're right :-)

Nic;o)
Apr 13 '07 #6
NeoPa
32,556 Expert Mod 16PB
I try with IN operator. This is right query:

Expand|Select|Wrap|Line Numbers
  1. SELECT type from TYPES WHERE type not in
  2. (SELECT type FROM name_type WHERE name="John")
thank you.
You should probably include the surname check too :
Expand|Select|Wrap|Line Numbers
  1. SELECT [Type]
  2. FROM [TYPES]
  3. WHERE [Type] NOT In
  4. (SELECT [Type]
  5.  FROM Name_Type
  6.  WHERE [Name]='John' AND [Surname]='Doe')
Apr 16 '07 #7

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

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"...
2
by: Colleyville Alan | last post by:
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...
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...
2
by: ilikebirds | last post by:
In 1 Database(ttt) I currently have a Union Query that collects data from 4 databases (a,b,c,d) and then a MakeTable query that combines all of those into a table. ( Union A,B,C,D to make table in...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...

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.