A table 'Detail' is related with two 'Master' tables by two fields, foreign keys, in an exclusive way. Either with Master1_ID or Master2_ID (only one of it will have the value of the id of the Maestro table to which it is related, the other will be NULL).
I want to get in a MySQL query the Detail records joined to the corresponding master.
Tables:
Detail[DetailID, DetailTitle, Master1_ID, Master2_ID, ...]
Master1[MasterID, MasterTitle, ...]
Master2[MasterID, MasterTitle, ...]
Master1_ID is the foreign key of the table Master1 and Master2_ID the foreign key of the table Master2. Only one of the two fields will have a value from the table it corresponds to.
And these are the records of the query I want to get:
Query: [DetailID, DetailTitle, MasterID, MasterTitle]
It will be appreciated to have in mind performance issues.
Thank you very much.