Address to mailing list from Database

Getting your data onto paper - or the web - Discussing the reports features of Base
Post Reply
coretj
Posts: 1
Joined: Fri May 18, 2012 6:00 pm

Address to mailing list from Database

Post by coretj »

I built a form and table. The Data I'm inputting has multiple contacts and addresses per record.

I need to be able to print out a mailing list for each contact but I can't figure out how.

I'm new at this so please help me using easy to understand explanations.
OpenOffice 3.2.0.10 || OOO320m12 Build (9483)
Ubuntu 10.04 LTS
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Address to mailing list from Database

Post by Villeroy »

Each contact can have more than one address, so this is a many-to-many relation which requires 3 tables just like the relation between persons and things in the database attached to this topic: http://user.services.openoffice.org/en/ ... 00&t=40444
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Address to mailing list from Database

Post by Villeroy »

OK, you may also implement a one-to-many relation where you collect contacts and addresses where each address belongs to one person with a slight chance of duplicate addresses.
You get the full mailing list from

Code: Select all

SELECT <personal fields>, <address fields> FROM "PersonTable","AddressTable" WHERE "PersonTable"."ID"="AddressTable"."PersonID"
If you want to keep a single table since no contact will ever have more than two or three addresses, then you get all the addresses with a query like this one:

Code: Select all

SELECT <personal fields>, <address_1 fields> FROM "table name" WHERE (NOT "City_1" IS NULL) AND (NOT "Addr_1" IS NULL) AND (NOT "ZIP_1" IS NULL)
UNION
SELECT <personal fields>, <address_2 fields> FROM "table name" WHERE (NOT "City_2" IS NULL) AND (NOT "Addr_2" IS NULL) AND (NOT "ZIP_2" IS NULL)
UNION
SELECT <personal fields>, <address_3 fields> FROM "table name" WHERE (NOT "City_3" IS NULL) AND (NOT "Addr_3" IS NULL) AND (NOT "ZIP_3" IS NULL)
UNIONs need to be run in direct SQL mode.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply