Cam someone please convert the below SQL query to SOQL?
SQL:
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?
Thanks
Cam someone please convert the below SQL query to SOQL?
SQL:
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?
Thanks
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