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
Software EngineSoftware Engine 

join in soql

Can some one help us with the below query.
 
I need to fetch the data from Opportunity, Account and Contact tables.
 
We have two rows available in Oppertunity Table and have one corresponding row in Account and Contact table. When we fetch the data using OppertunityContacRole table we always getting only one row as a result.
So we used the query
select opportunity.CE_Lead_Ref__c,
opportunity.CloseDate,
opportunity.Order_Type__c,
opportunity.Order_Channel__c,
opportunity.Electric_Utility__c,
opportunity.Gas_Utility__c,
opportunity.QA_Done__c,
opportunity.Product_ID__c,
opportunity.oem_entered_date__c,
opportunity.Gas_Product_ID__C,
opportunity.Electric_Sales_Price__c,
opportunity.Gas_Sales_Price__c,
opportunity.Electric_Utility_Account_ID__c,
opportunity.Gas_Utility_Account__c,
opportunity.ORDER_CHNL_VENDOR_CD__c,
opportunity.PROMOTION_CD__c,
opportunity.Account.Name,
opportunity.Name,
opportunity.Service_Address_1__c,
opportunity.Service_Address_2__c,
opportunity.Account.Description,
Opportunity.Account.BillingStreet,
Opportunity.Account.BillingPostalCode,
Opportunity.Account.BillingCity,
Opportunity.Account.BillingState,
opportunity.Account.Other_Phone__c,
opportunity.Opportunity_Decatherms__c,
opportunity.Opportunity_kwh__c,
Opportunity.Electric_Voice_Log_Ref__c,
Opportunity.Gas_Voice_Log_Ref__c,
opportunity.SSN_TaxID__c,
Opportunity.Fed_Tax_ID__c,
opportunity.Service_City__c,
opportunity.Service_State__c,
opportunity.Bill_Due_Date__c,
opportunity.Aggregator_Location__c,
opportunity.Aggregator__c,
opportunity.Service_Zip__c,
opportunity.Account.Phone,
opportunity.owner.name,
opportunity.stagename,
opportunity.Language_Preference__c,
opportunity.Life_Support__c,
opportunity.Tax_Exempt__c,
opportunity.Tax_Exempt_ID__c,
opportunity.DOB__c,
(select contact.FirstName, contact.LastName, contact.Phone, contact.Email, Contact.Title from opportunitycontactroles),
opportunity.Owner.REPID__c,
opportunity.Customer_type__c,
opportunity.SSN_Tax_ID_Masked__c,
opportunity.Effective_Date__c,
opportunity.Campaign.Campaign_Code__c from Opportunity
 
Within VB.NET code we assign a variable to get opportunity values,
eg :

qr = m_Prodbinding.query(QueryStr)

Dim con As Prod_Sforce.Opportunity = qr.records(i - 1)

 

But we are not able to get the Contact table details which is part of inner select query. Pls advise.

Thanks,

Priya

NasipuriNasipuri

Hi ,

SOQL does not support join.

You have to use relationship query for this.

Find the help section for the detail about relationship query.

 

Regards,

Dinesh Nasipuri

 

SuperfellSuperfell
Can you expand on what exactly is not working ?

con.OpportunityContactRoles should return you a queryResult with the results of the child query.