Here's the query:
Merchandise__c[] merchList = Database.query('SELECT ' + lookupFieldApiName +'.Id, '+ lookupFieldApiName +'.Name ' +
'FROM Merchandise__c ' +
'WHERE Product__c =:productId '+ merchTypeQuery + ' ' + machineConfigQuery );
What i'm trying to do is narrow this down into a list where the lookupFieldApiName.Id doesn't repeat.
The purpose is to add options to a lightning combobox on a form, the reason i need to do this is because i'm creating a dynamic combobox(picklist/selectOption) based on a hierarchy and standard picklists for a multitude of business reasons.
Also yes i've looked at other solutions but other than going wild and doing an O(n^2) algorithm, which i'd rather not, i'm not sure what i can do here.