I have 2 tables a car model and car parts. Both are related with a partfitment table whose only fields are the primary keys modelID and partID.
I am trying to display the parts that fit the model car I selected.
The following works fine:
INNER JOIN tblpartfitment
ON tblmodel.modelID = tblpartfitment.modelID)
INNER JOIN tblparts
ON tblpartfitment.partID = tblparts.partID
WHERE tblmodel.modelID = 1;
I think you can just include the logic in the
SELECT m.ModelID, m.Model, p.part, p.part_number, p.description, p.list_price FROM tblmodel m INNER JOIN tblpartfitment pf ON m.ModelID = pf.modelID INNER JOIN tblparts p ON pf.partID = p.partID OR p.universal_part = 1 WHERE m.ModelID = 1;