I have a table in my database that has two columns. The first column has some names of individuals and the second column has some group names. I have another table with over 500,000 records. What I want to do is to do a lookup of sorts on the two column table and wherever the individual name comes up in the large table, to return the group name. I am able to change the name with this query:
UPDATE CommonNames
SET Customer = 'Group A'
WHERE Customer = 'Bill Smith.'
OR Customer = 'John Smith'
OR Customer = 'Aaron Smith'
But then I will have to constantly update my query when the two column table changes (frequently). Is there a query I could use that does a lookup on the two column table and based on what's there changes the large table? Your help is greatly appreciated.
Chris
2007-06-21
04:06:58
·
3 answers
·
asked by
Mr Chris
4
in
Computers & Internet
➔ Programming & Design
Unfortunately I can not add fields to either table. Also, my smith example was a poor one in the accounts being grouped will not necesarily have any common characteristics. The large table is a customer list. The small table is all of the major customers that have different businesses. So, if for tax reasons, person X decides to open Person X, LLC and that shows up in next month's data, I want to be able to get that grouped with the rest of Person X's accounts. So the company names will never change groups, some may go away from time to time, but there are new company names being added constantly.
2007-06-21
07:16:11 ·
update #1
Thank you everyone for your help, but I just got it working. The query that I used was:
Update LargeTable
Set Customer = SmallTable.Groups
From LargeTable, SmallTable
Where LargeTable.customer = SmallTable.customer
Again, thank you everyone for your help
2007-06-21
07:40:52 ·
update #2