PC Review


Reply
Thread Tools Rate Thread

Comparing tables to locate zero values

 
 
=?Utf-8?B?U0lUQ0ZhblRO?=
Guest
Posts: n/a
 
      14th Jun 2007
I have a table named "tblAllFiles" that contains a col named "Salesman".
Every record will have a salesman assigned to it in the tblAllFiles table.
Then I have another table named "tblStaff" with "Salesman", "Secondary
Salesman" and Primary Salesman" columns. I need to compare these two tables
and identify records in the "tblAllFiles" where the "Salesman" name is not in
the "tblStaff" table. How can I do this easily. We add new salesman and I
need to be sure that the tables are always in synch. Thank you.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?T2ZlciBDb2hlbg==?=
Guest
Posts: n/a
 
      14th Jun 2007
You can use the query wizard to create an UnMatch record query to list all
the records that are in one table but not in the other

--
Good Luck
BS"D


"SITCFanTN" wrote:

> I have a table named "tblAllFiles" that contains a col named "Salesman".
> Every record will have a salesman assigned to it in the tblAllFiles table.
> Then I have another table named "tblStaff" with "Salesman", "Secondary
> Salesman" and Primary Salesman" columns. I need to compare these two tables
> and identify records in the "tblAllFiles" where the "Salesman" name is not in
> the "tblStaff" table. How can I do this easily. We add new salesman and I
> need to be sure that the tables are always in synch. Thank you.

 
Reply With Quote
 
=?Utf-8?B?U0lUQ0ZhblRO?=
Guest
Posts: n/a
 
      14th Jun 2007
I've dont' know....I've never heard of Unmatch query...can you step me though
that. I appreciate your help, thank you.

"Ofer Cohen" wrote:

> You can use the query wizard to create an UnMatch record query to list all
> the records that are in one table but not in the other
>
> --
> Good Luck
> BS"D
>
>
> "SITCFanTN" wrote:
>
> > I have a table named "tblAllFiles" that contains a col named "Salesman".
> > Every record will have a salesman assigned to it in the tblAllFiles table.
> > Then I have another table named "tblStaff" with "Salesman", "Secondary
> > Salesman" and Primary Salesman" columns. I need to compare these two tables
> > and identify records in the "tblAllFiles" where the "Salesman" name is not in
> > the "tblStaff" table. How can I do this easily. We add new salesman and I
> > need to be sure that the tables are always in synch. Thank you.

 
Reply With Quote
 
=?Utf-8?B?SmVycnkgV2hpdHRsZQ==?=
Guest
Posts: n/a
 
      14th Jun 2007
The best way to do it (which means not easy). Break out or redesign your
tblStaff. It should not have individual "Salesman", "Secondary Salesman" and
"Primary Salesman" columns. Rather it should have either a TypeSaleman column
with Salesman", "Secondary Salesman" and "Primary Salesman" as the valid
entries.

If a saleman can be different types, you may even need another table.

Next you would open the relationship window and join the tblAllFiles and
tblStaff tables on the appropiate primany and foriegn key fields. Next
enforce Referiental Integrity so that it is impossible to have a salesman in
tblAllFiles without a match in tblStaff.

Now the "easy" way to find out where you have 'orphans'. Note that this
tells you about problems and doesn't prevent them from happening again.
Create a query as follows and name it "qrySalemanMissing":

SELECT Salesman
FROM tblAllFiles
WHERE Salesman
NOT IN (SELECT Salesman FROM
(SELECT Salesman
FROM tblStaff
WHERE Salesman Is Not Null
UNION
SELECT [Secondary Salesman]
FROM tblStaff
WHERE [Secondary Salesman] Is Not Null
UNION
SELECT [Primary Salesman]
FROM tblStaff
WHERE [Primary Salesman] Is Not Null )) ;

--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"SITCFanTN" wrote:

> I have a table named "tblAllFiles" that contains a col named "Salesman".
> Every record will have a salesman assigned to it in the tblAllFiles table.
> Then I have another table named "tblStaff" with "Salesman", "Secondary
> Salesman" and Primary Salesman" columns. I need to compare these two tables
> and identify records in the "tblAllFiles" where the "Salesman" name is not in
> the "tblStaff" table. How can I do this easily. We add new salesman and I
> need to be sure that the tables are always in synch. Thank you.

 
Reply With Quote
 
=?Utf-8?B?T2ZlciBDb2hlbg==?=
Guest
Posts: n/a
 
      14th Jun 2007
When you create a query, you can select query wizard.
One of the options is UnMach Record query

Try this SQL, hopefuly the names are correct

SELECT tblAllFiles.Salesman
FROM (tblAllFiles LEFT JOIN tblStaff ON tblAllFiles.Salesman =
tblStaff.[Primary Salesman]) LEFT JOIN tblStaff AS tblStaff_1 ON
tblAllFiles.Salesman = tblStaff_1.[Secondary Salesman]
WHERE tblStaff.[Primary Salesman] Is Null
AND tblStaff_1.[Secondary Salesman] Is Null

--
Good Luck
BS"D


"SITCFanTN" wrote:

> I've dont' know....I've never heard of Unmatch query...can you step me though
> that. I appreciate your help, thank you.
>
> "Ofer Cohen" wrote:
>
> > You can use the query wizard to create an UnMatch record query to list all
> > the records that are in one table but not in the other
> >
> > --
> > Good Luck
> > BS"D
> >
> >
> > "SITCFanTN" wrote:
> >
> > > I have a table named "tblAllFiles" that contains a col named "Salesman".
> > > Every record will have a salesman assigned to it in the tblAllFiles table.
> > > Then I have another table named "tblStaff" with "Salesman", "Secondary
> > > Salesman" and Primary Salesman" columns. I need to compare these two tables
> > > and identify records in the "tblAllFiles" where the "Salesman" name is not in
> > > the "tblStaff" table. How can I do this easily. We add new salesman and I
> > > need to be sure that the tables are always in synch. Thank you.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing values in two columns and displaying missing values in n =?Utf-8?B?Y3BldHRh?= Microsoft Excel Programming 1 2nd Apr 2005 06:18 AM
Graph - comparing values of 2 series while adding an attribute for each compared values Chen G Microsoft Excel Charting 2 1st Nov 2004 07:08 PM
Graph - comparing values of 2 series while adding an attribute for each compared values Chen G Microsoft Excel Misc 1 1st Nov 2004 02:44 AM
Comparing values in same field to return only first unique values =?Utf-8?B?U0Q=?= Microsoft Access Queries 4 27th Oct 2004 08:24 AM
comparing 2 values from 2 tables Kim Microsoft Access VBA Modules 1 1st Feb 2004 06:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:15 AM.