Cam someone please convert the below SQL query to SOQL?
Select id, Name, product_code, (select product_code from product b where b.parent_id=a. id) as parent_code from product a
How to get these results through in salesforce/SOQL?
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
You're trying to do a
Left Outer Join.
First step is to find the child relationship name. If you have a custom lookup, it's going to end in
__r and it's usually plural. So for example if it were
Products__r, you would do:
SELECT (SELECT Product_Code__c FROM Products__r) FROM Parent_Object__c