function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
lijin Devlijin Dev 

How to lookup from another Salesforce Table within SOQL?

I got these tables in Salesforce 
Opportunity with  Drop ID  and MBK Key  ( along with other fields)
&
Opportunity_lineitem  with IO Key, Drop ID  

Drop ID is common across and I need to tweak the below SOQL to bring  MDK Code from Opportunity. Is this possible?

Select
IO Key, Drop ID
From Opportunity_linitem
Best Answer chosen by lijin Dev
Arjun AccentureArjun Accenture
so here you can do like this then

select id, Opportunity.Procedure_Distal_Lead_Placement__c from OpportunityLineItem where Opportunity.MDKCode IN ('0001','0011','0111') AND other where condition as well.

Please feel free to reach in case still not done.

and please mark it as best answer as well.

Regards
Arjun Soni

All Answers

Arjun AccentureArjun Accenture
is it solving your issue ??

if no please clarify your question.

Select id,MDKCode ,(select IO Key, Drop ID From Opportunity_linitem) from Opportunity where group by MDKCode
lijin Devlijin Dev
Thanks, Arjun.  I would like to have  Opportunity_linitem as my FROM.   As it was easy for me to keep a lot of WHERE condition at an Opportunity_linitem level.  With the approach provided by you,  my resultant  table may return lot of unwanted records 
Arjun AccentureArjun Accenture
so here you can do like this then

select id, Opportunity.Procedure_Distal_Lead_Placement__c from OpportunityLineItem where Opportunity.MDKCode IN ('0001','0011','0111') AND other where condition as well.

Please feel free to reach in case still not done.

and please mark it as best answer as well.

Regards
Arjun Soni
This was selected as the best answer