I have  table called addresses that stores N:N sub-information from those two tables people and companies.
So I created another table called address_links that have the fields address_id and contact_id so that contact id could come from a people or from a companies record.
So I need another field that by the creation of the record, points to the correct table. But what can I do to automatize that interpretation when I make a query that shows the name of the owners of that addresses in a query list? I tried IF in order to case that 3rd field by selecting the table but it did not worked.
Explain Note: Some address may be house or workplace for more than one person.