I have a large database of contacts, but since not all fields are used I
decided to separate all information in 3 tables to save space like this:
... three columns more ...
Not all addresses have necesarily a company name, so it is separate in a table
DB_COMPANY. Some other addresses are clasified in lists by category and they
are grouped in DB_LISTS table.
If I want a report with address and company name pairs I use:
select address,company from DB_ADDRESS left join DB_COMPANY on
DB_ADDRESS.id=DB_COMPANY.id where DB_COMPANY.id is not null;
If I want a report of address belonging to a certain category:
select address,list from DB_ADDRESS left join DB_LISTS on
DB_ADDRESS.id=DB_LISTS.id where DB_LISTS.id is not null and
BUT... If I want to generate a report with address, company and list
(category) how can I join the three tables with a single query? or should I
first generate a temporal table with the result of the first join and then a
second one joining the third table?
Thanks for your comments