Find and Change

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In basic terms: I have a table with fields of Social Security No, Name, and
Type (3 letters). There are multiple occurrences of the same SSN and Name,
but there may be different Types (e.g., AAA, BBB, CCC, etc). I need to find
all occurrences of Type CCC. I don't need to find anyone with Types AAA or
BBB. However, if I find multiple occurrences of the same SSN and Name, but
one record has AAA and another has CCC, then I need to change the AAA to CCC.
In other words, if a person has the Type CCC, then all occurrences of this
person need to have CCC. I hope this makes sense.

Any suggestions? Thanks for your help in advance.
 
James Kennedy said:
In basic terms: I have a table with fields of Social Security No, Name,
and
Type (3 letters). There are multiple occurrences of the same SSN and
Name,
but there may be different Types (e.g., AAA, BBB, CCC, etc). I need to
find
all occurrences of Type CCC. I don't need to find anyone with Types AAA
or
BBB. However, if I find multiple occurrences of the same SSN and Name,
but
one record has AAA and another has CCC, then I need to change the AAA to
CCC.
In other words, if a person has the Type CCC, then all occurrences of this
person need to have CCC. I hope this makes sense.

Any suggestions? Thanks for your help in advance.

UPDATE

SET [Type]="CCC"
WHERE Type<> "CCC" AND SSN IN
(SELECT SSN FROM
WHERE Type="CCC")

Carl Rapson
 
Use two queries unless you know subquires. Change table name from James to
your table. The first query is named James_1.
SELECT James.Type, James.[Social Security No]
FROM James
WHERE (((James.Type)="CCC"));

UPDATE James_1 INNER JOIN James ON James_1.[Social Security No] =
James.[Social Security No] SET James.Type = "CCC";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top