I have 3 tables:
addresses
id, address, city, zipcode
persons (1500 records)
id, address_id, firtname, lastname, sex, title
buildings (100 records)
id, address_id, name, type_of_building
Multiple persons/buildings share the same address. I need to list all addresses with its person or building info. So, my query should return a total of 1600 records.
What kind of query do I need to write to retrieve this information?
Because you need all of the records from two different datasets, you need to use an
INNER JOINwith aUNION. Something like this might work: