Query that will look for duplicate in two tables.

I have two tables that were originaly Excel tables and imported them into 
Access. Import went well. Both tables consist of columns named - Name, 
Department Number, Department Name, and Employee ID. I need to compare the 
two tables and have Access give me the NON duplicates. 
I ran a Find Unmatched Query using name in both tables. The results showed 
almost as many records as are in the original two tables. What I noticed it 
found in one table Smith, John and Smith,John. These are the same people but 
one person typed the name with the last name and comma space while the other 
person who typed the other table omitted the space. Therefore I think the 
query is seeing this as two seperate people because they do not match 
exactly? Unfortunatly they left the name coulmn with the last ane and first 
name not seperated into two separate fields.
Any help would be appreciated.
0
Utf
3/9/2010 9:24:05 PM
access.queries 6343 articles. 1 followers. Follow

3 Replies
1457 Views

Similar Articles

[PageSpeed] 52

On Tue, 9 Mar 2010 13:24:05 -0800, John <John@discussions.microsoft.com>
wrote:

>I have two tables that were originaly Excel tables and imported them into 
>Access. Import went well. Both tables consist of columns named - Name, 
>Department Number, Department Name, and Employee ID. I need to compare the 
>two tables and have Access give me the NON duplicates. 
>I ran a Find Unmatched Query using name in both tables. The results showed 
>almost as many records as are in the original two tables. What I noticed it 
>found in one table Smith, John and Smith,John. These are the same people but 
>one person typed the name with the last name and comma space while the other 
>person who typed the other table omitted the space. Therefore I think the 
>query is seeing this as two seperate people because they do not match 
>exactly? Unfortunatly they left the name coulmn with the last ane and first 
>name not seperated into two separate fields.
>Any help would be appreciated.

A rather complicated query should do (most of) this for you. Assuming that
your tables are named Table1 and Table2, put this SQL into the SQL view of a
new query (edit the tablenames of course):

SELECT Table1.*
FROM Table1
LEFT JOIN Table2
ON Table2.[Name] LIKE Trim(Left([Table1].[Name], InStr([Table1].[Name], ",") -
1)) & "*"
AND Table2.[Name] LIKE "*" & Trim(Mid([Table1].[Name], InStr([Table1].[Name],
",") + 1)
WHERE Table2.[Name] IS NULL;

This should find record which have a Name in Table1 which does not exist in
Table2. You can then edit the query swapping the tablenames to get the
mismatches in the other direction.

Unfortunately, if there's a Bob Jones in Table1 who called himself Robert
Jones in Table2, there'll be no match. And of course if there are two people
named Jim Smith in Table1 only one of whom is in Table2, you won't find the
discrepancy without a much more complex query.

I hope these records will end up in some normalized tables - there should, for
example, be a single Departments table with a primary key DepartmentID, and an
People table with fields PersonID (primary key), LastName, FirstName,
DepartmentID.
-- 

             John W. Vinson [MVP]
0
John
3/9/2010 10:43:38 PM
John
Thanks for your help. I entered the SQL statement, but somewhere I must have 
typed it wrong because now when I run the query I receive a parameter box 
titled Tax List and looking for something to be typed into it. As I stated in 
my previous question below. I need to find the values in the Tax List table 
that do not have corresponding vlaues in the Annette Gift Card table. Basicly 
i am looking for employees who were taxed for a gift card (tax list table) 
but did not actually recive a gift card (Annette gift card list - these 
employees actually received a gift card and should be taxed). 
Here is my query as typed in the SQL editor:
SELECT TaxList.*
FROM TaxList
LEFT JOIN AnnetteGiftCardList
ON AnnetteGiftCardList.[Name] LIKE Trim(Left([TaxList].[Employee_Name], 
InStr([TaxList],[Employee_Name], ",") - 1)) & "*"
AND AnnetteGiftCardList.[Name] LIKE "*" & 
Trim(Mid([TaxList].[Employee_Name], InStr([TaxList].[Employee_Name], ",") + 
1))
WHERE AnnetteGiftCardList.[Name] IS NULL;

"John W. Vinson" wrote:

> On Tue, 9 Mar 2010 13:24:05 -0800, John <John@discussions.microsoft.com>
> wrote:
> 
> >I have two tables that were originaly Excel tables and imported them into 
> >Access. Import went well. Both tables consist of columns named - Name, 
> >Department Number, Department Name, and Employee ID. I need to compare the 
> >two tables and have Access give me the NON duplicates. 
> >I ran a Find Unmatched Query using name in both tables. The results showed 
> >almost as many records as are in the original two tables. What I noticed it 
> >found in one table Smith, John and Smith,John. These are the same people but 
> >one person typed the name with the last name and comma space while the other 
> >person who typed the other table omitted the space. Therefore I think the 
> >query is seeing this as two seperate people because they do not match 
> >exactly? Unfortunatly they left the name coulmn with the last ane and first 
> >name not seperated into two separate fields.
> >Any help would be appreciated.
> 
> A rather complicated query should do (most of) this for you. Assuming that
> your tables are named Table1 and Table2, put this SQL into the SQL view of a
> new query (edit the tablenames of course):
> 
> SELECT Table1.*
> FROM Table1
> LEFT JOIN Table2
> ON Table2.[Name] LIKE Trim(Left([Table1].[Name], InStr([Table1].[Name], ",") -
> 1)) & "*"
> AND Table2.[Name] LIKE "*" & Trim(Mid([Table1].[Name], InStr([Table1].[Name],
> ",") + 1)
> WHERE Table2.[Name] IS NULL;
> 
> This should find record which have a Name in Table1 which does not exist in
> Table2. You can then edit the query swapping the tablenames to get the
> mismatches in the other direction.
> 
> Unfortunately, if there's a Bob Jones in Table1 who called himself Robert
> Jones in Table2, there'll be no match. And of course if there are two people
> named Jim Smith in Table1 only one of whom is in Table2, you won't find the
> discrepancy without a much more complex query.
> 
> I hope these records will end up in some normalized tables - there should, for
> example, be a single Departments table with a primary key DepartmentID, and an
> People table with fields PersonID (primary key), LastName, FirstName,
> DepartmentID.
> -- 
> 
>              John W. Vinson [MVP]
> .
> 
0
Utf
3/10/2010 7:46:02 PM
On Wed, 10 Mar 2010 11:46:02 -0800, John <John@discussions.microsoft.com>
wrote:

>John
>Thanks for your help. I entered the SQL statement, but somewhere I must have 
>typed it wrong because now when I run the query I receive a parameter box 
>titled Tax List and looking for something to be typed into it. As I stated in 
>my previous question below. I need to find the values in the Tax List table 
>that do not have corresponding vlaues in the Annette Gift Card table. Basicly 
>i am looking for employees who were taxed for a gift card (tax list table) 
>but did not actually recive a gift card (Annette gift card list - these 
>employees actually received a gift card and should be taxed). 
>Here is my query as typed in the SQL editor:
>SELECT TaxList.*
>FROM TaxList
>LEFT JOIN AnnetteGiftCardList
>ON AnnetteGiftCardList.[Name] LIKE Trim(Left([TaxList].[Employee_Name], 
>InStr([TaxList],[Employee_Name], ",") - 1)) & "*"
>AND AnnetteGiftCardList.[Name] LIKE "*" & 
>Trim(Mid([TaxList].[Employee_Name], InStr([TaxList].[Employee_Name], ",") + 
>1))
>WHERE AnnetteGiftCardList.[Name] IS NULL;

Is the name of the table TaxList? or Tax List? What is the *actual* error
message? What are some actual values from the Employee_Name and Name fields? 

You might try putting the Trim expressions into a vacant Field cell just to
see how they're being interpreted.
-- 

             John W. Vinson [MVP]
0
John
3/11/2010 2:13:51 AM
Reply:

Similar Artilces:

Timer for Queries?
Does anyone know of a macro or add-on that I could use as a simple timer for queries? I don't like to use the CPU time in the Task Manager because of it's inaccuracy when not receiving full CPU usage. THanks for any suggestions -- cmungs Exactly what are you trying to accomplish? Are you trying to cause a query to run automatically every so often? If so, you will need to use the timer event on a form to do that. -- Lynn Trapp Microsoft MVP (Access) www.ltcomputerdesigns.com "cmungs" <cmungs@discussions.microsoft.com> wrote in message news:88EC7019-045F-4EF...

Will Excel tell me when a date is near?
Hi all, I was just wondering if Excel is capable of alerting its user when date is near or when it has arrived. I know that alot of calande programs will do this however those programs wont keep track of th other information I need. I am trying to keep a list of my buisness' clients and when thie insurance expires. I would like a pop up message or some other type o alert when a date comes near. I dont know if Excel can even do this. Any suggestions will help. Thank -- Message posted from http://www.ExcelForum.com Here's a technique that I discovered a few weeks ago, and I am ...

Erratic results from query criteria
I am getting different results from running the same query with the same selections. One moment it is all behaving as expected, the next it has gone haywire. (I have done what appears to me to be EXACTLY what I have done in another database, where it works perfectly every single time.) In a query I have, amongst others, the following fields: Category SubCategory Company I want to be able to select any OR ALL of the relevant fields. I have the following criteria: Like "*"&[Type Category otherwise leave blank for ALL]&"*" Like "*"&a...

Updating Data from two different worksheets
I have two worksheets, General Ledger and Out Ledger. The general ledge lists our inventory according to a LOT ID and the total number of item in that lot; i.e. column A: Lot ID, column B: Total Number of Pieces column C: Balance The Out Ledger lists the number of items sold from a particular lot i.e. column A: Lot ID, column B: Number Sold I want to be able to calculate the Balance in the General Ledger give the Number Sold in the Out Ledger. I am having difficulty in makin sure the Lot ID's match up and that the proper cells are referenced. Any suggestions/advice would be greatly appr...

Update Query ?
Is there a way to 1) Assign events when adding in data thru an update query for example if you append a bunch of data into a table could you then do some kind of an update query to say if there is an initial event and no others tag this one Renewal 1 etc.. the only real data you have to go on would be Customer A and the total amt .. the event, renewal event and the delta would all need to be added in example: Say Customer A comes in with an initial deal then Customer A renews their deal So, the data would look like when you're done.: Year Custo...

Matching data in tables
I have two tables of data, some of the rows are duplicated in these tables i want to find the data that is different. will an advanced filter do this? Chip Pearson has lots of info about working with duplicates at: http://www.cpearson.com/excel/duplicat.htm Jo Davis wrote: > > I have two tables of data, some of the rows are duplicated in these tables i > want to find the data that is different. > > will an advanced filter do this? -- Dave Peterson Cheers Dave "Dave Peterson" wrote: > Chip Pearson has lots of info about working with duplicates at: >...

design query match anywhere?
In the design query I want to match the letters "ABC" anywhere in the column 'description'. I could not get instr to work by using: InStr(description, "ABC")) > 0 How else can I match ABC (upper and lowercase) to anywhere in my 'description' column? Thanks! Are you saying you put that InStr bit as a criteria under your Description field in the query designer? Try putting Like "*ABC*" as the criteria instead. Alternatively, you could add a computed field to the query InStr([Description, "ABC") and then put >0 as the ...

Two different organizers in one meting
imagine the folowing: Person A is the assistant of Person B, who has given delegation on his calender. When person A makes a meeting request in the calendar of person B and has made a reservation of a resource (meeting room), everything seems to be working fine. however, when person A opens the meeting request in the calendar folder of Person B, I can see that the organizer of the meeting is Person B. When I open the meeting in the calendar of the resource mailbox, the organizer of the meeting is Person A ?? This occurs with Outlook 2007 SP2 and Exchange 2010. Is there a way t...

Two questions
Hey everyone, I have two questions: 1. I have created a patient manager database that tracks appointments, billing, and medications. I have 4 subforms within a main form. I want to be able to create one main record with subrecords for appointments, billing, and medication associated to it. Can this be done? 2. Everytime I am in the database, other users can't save their records. How do I change this and still limit user access? Thank you in advance. -- bhsvixon On Thu, 11 Feb 2010 11:59:02 -0800, 1encapdiva <tgrandberry@encapomaha.org> wrote: >Hey ever...

Unexpected Error- Running Advance Find Query
I am getting a message that says "Unexpected Error An Error has occurred" when I am running an advanced find query on two custom entities. It seems to be when I have certain custom fields included in my view that the query errors out. Any help on this would be greatly appreciated. Thanks so much. Just wanted to add that I seem to get errors when there is a 0.00 amount in these fields... "TJ" wrote: > I am getting a message that says "Unexpected Error An Error has occurred" > when I am running an advanced find query on two custom entities. It se...

Pivot Table Summary Error?
Greetings, Sorry, wasn't sure which subforum to post this in, as there's nothing dedicated to pivot table. My dilemma is as follows: I have a spreadsheet where data is entered daily. For my example, just imagine a spreadsheet with three columns: date, date, delay. Two date columns are used for the pivot table. The pivot table is displayed with month and weekly ranges as the row headers. There is a field in the pivot table that is summarized as a MAX of one of the source data columns. Now, the problem I am coming across is the monthly summary MAX is not c...

Removing a field From a Pivot Table
I'm working with a pvt table in excel. Right now there are several fields in the pvt table, including the month different entries are made and the account that made them. When i hit the show detail button in the pivot table i get the detail all of the entries grouped by month and by account on a separate sheet. I want to continue to do this, but i want to also be able to get a second view where i hit the show detail button and only see the detail grouped my account (month is either hidden or totally removed from this list of data in the pvt table and the rows that composed the different...

pass through query
If a combobox is populated by a pass-through query, does it requery every time the form is closed and reopened? Thanks, Sam Yes. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County Sam wrote: > If a combobox is populated by a pass-through query, does it requery every > time the form is closed and reopened? > Thanks, > Sam ...

a count field in a query?
Hello, I have a query in which I would like to create a field which increments by 1 for each record selected, so if there are 10 records selected by the query, this column would show numbers 1 to 10. Ideally I would like to have some text in front of each number, say invoice1, invoice2 etc. From a previous posting I realise that this is frowned upon but it would be the simplest solution for my problem! How can I do this? Thanks Geoff On Mon, 03 Dec 2007 08:54:00 +0000, Geoff Cox <<>> wrote: >Hello, > >I have a query in which I would like to create a field which >...

Link Drop Down list with Pivot Table
Hi I'm using MS Excel 2003 and need a solution regarding link my drop down list with my pivot table. Query : I have created a drop down list in which month can be selected and wanted to link with pivot table in which month wise team count is displayed for a selected month. Presently I'm drag n drop the month in pivot table and its shows the count. But this exercise I have to do every time when I need the report. Is it possible that I have select the month from my drop down list (created in same sheet) and pivot table shows the data related to that month. Ple...

Saving Username and Pass with Web Queries
I am pulling data from a website that requires you to provide a usernam and password everytime you visit the site. Excel has cachin capabilities, but everytime you close excel and try and open up th spreadsheet again, it can't login. What is the fix for this? Thanks, Hend -- Message posted from http://www.ExcelForum.com Bump! --- Message posted from http://www.ExcelForum.com/ ...

Location of Grand Total in Pivot table
Is the a way to show the Grand total next to the selected Field as opposed to the right now column ( I am using a file that had data results by Date)? You can not move the grand totals. They is where they is and that's where they stays... -- HTH... Jim Thomlinson "Rosemary" wrote: > Is the a way to show the Grand total next to the selected Field as opposed to > the right now column ( I am using a file that had data results by Date)? ...

Birthday query for many children in one record
I have a database for the church, it has one main flat table only. Each record for the parents have field for child1 name, child1birthday, child2 name, child2birthday, child3 name, child3birthday - up to 5 children. I am having difficulty trying to get a report to list the birthdays of the children like this parent name, child 1 name, child 1 birthday month etc. so you get something like this:- Parent John Smith, child Mary Smith January 3 Parent Fred Jones, child Bert Jones March 4 Parent John Smith, child Jane Smith March 6 Parent Harry Brown, child Jane Brown March 6 Parent Bert Taylor,...

Unresponsive Query Wizard
Hi there, I have an Excel 2003 user who is using a spreadsheet that pulls data from our SQL server. When he opens it and refreshes the data it is fine, it pulls the current data, but when he tries to edit the query, the Query Wizard does not appear, he can see it on the task bar, but when he switches focus using task manager everything is greyed out and nothing works. I have tested the file from my computer and it is fine, which suggests a problem with his machine or installation. Does anyone have any ideas? Cheers, Steve Dooza wrote: > Hi there, > I have an Excel 2003 user who...

Another simple query
Dear all, I have a table that contains first names and last names in different fields. Is there any way to write a query that will give as a result the first name and last name in the same field? I hope this makes sense. Thanks in advance! SELECT [last_name_field] & ", " & [first_name_field] AS whole_name FROM [your_name_table] Change the field and table names to whatever your actual fields and tables are. Cheers, Jason Lepack On Apr 23, 9:47 am, Homer <peter.a.r...@googlemail.com> wrote: > Dear all, > > I have a table that contains first names an...

How do I nail how the new message window looks when I open it?
In Outlook 2000 SR-1 Corporate or Workgroup, when I start a new message the way in which the toolbars appear in the new message window is not to my liking. I can drag them around and get them to look like what I would prefer, but this gets tedious after a while. How can I set the default toolbar arrangement for new messages such that it sticks between sessions? ...

Sorting Cube dimension names in a Pivot Table
How do I get the dimension names in the "pivot table field list" sorted by the translated names? The pivot table field list contains: - one measure-node - one dimension node for each cube-dimension. The cube-dimension-nodes are represented by their translated names. It looks like, this names are not sorted by this translated names, but by the order of the data source. The related radio-buttons in the pivot-table-options are greyed ("A to Z" and "sort by data source"). I would need the "A" to "Z" order. Pleas notice! I...

Query query
I am trying to create a new field in which it shows the sum total of 10 fields (Charge Time, Charge Time 2, Charge Time 3, etc.); what is the easiest way to do this? -- Joe NewFieldName: [Charge Time] + [Charge Time 2] + [Charge Time 3] .... etc -- Good Luck BS"D "joet5402" wrote: > I am trying to create a new field in which it shows the sum total of 10 > fields (Charge Time, Charge Time 2, Charge Time 3, etc.); what is the easiest > way to do this? > -- > Joe I tried this, and it doesn't work. Is there something I'm forgetting? -- Joe ...

Duplicate messages coming into inbox
We had a problem with 7040 messages re-coming into our inbox from June 2009 through April 2010 this past Saturday. We had turned our computer off for the first time in 30 days. We are using 5 different email accounts within the same version of Outlook and only the MSN email account gave us duplicates. We called their support and they said there was no server outage or anything that might have caused this duplication. Now we're trying to find the Outlook set up that might be causing the problem. All of our email settings use POP/STMP in Tools/Account Settings on the Email tab....

group by query trouble
I'm trying to run a query that counts the number of people with hemoglobin of type SS, type SC, and then all others. There are about 12 different kinds of types. Basically I want a count for SS, a count for SC, and then a count that totals all the others into one count. Hopefully that makes sense. I'm using group by for the SS and SC which works great, but I'm not sure how to tell it to add up the others. I'm not a big fan of nested IIf statements, but this should work after you put in the proper field and table names: SELECT IIf([Hemoglobin]="SC","SC&...