create a new table combining Mr. and Mrs. records

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

Guest

Hello, and thanks for your time.
I have a database set up with approx 300 church members. The wife is one
record and the husband is another record. Since the two of them contribute
together, I think I need to create a new table that would find matching
addresses and put both first names into one record. Is there a sample query
that would do this? Also I need to print mailing labels combining multiples
at one address. Am I on the right track?
 
If it were me, I would have one table with...

PrimaryKey (Household number? Account number?)
MainFirstName
MainLastName
SecondaryFirstName
SecondaryLastName
Address1
Address2
City
State
..
..
..


Rick B
 
I had a go at doing this using a self-join. For testing purposes, I added a
HouseHold field to the Employees table in the Northwind sample database, and
I came up with the following query ...

SELECT Employees.Household, First(Employees.LastName) AS FirstOfLastName,
First(Employees.FirstName) AS FirstOfFirstName, First(Employees_1.LastName)
AS FirstOfLastName1, First(Employees_1.FirstName) AS FirstOfFirstName1
FROM Employees INNER JOIN Employees AS Employees_1 ON Employees.Household =
Employees_1.Household
GROUP BY Employees.Household;

This almost works. But there is an odd number of employees in Northwind, so
Anne Dodsworth ends up as a single parent, and gets returned on both sides
of the join. You could probably handle that with an IIf() to detect whether
FirstOfLastName = FirstOfLastName1 and FirstOfFirstName = FirstOfFirstName1,
but that might be better handled in the report than in the query.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top