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
Rathna DeshmukhRathna Deshmukh 

Query multiple objects using SOAP API

HI,

I need to query Account records and also opportunities associated with that account based on Account Id using SOAP API enterprise wsdl.

I there a way to fetch this data in a single call,rather than making 2 seperate Query calls.currenlty I am using 2 seperate query calls to achieve this.

Please help.
Thanks in Advance!!
Boris BachovskiBoris Bachovski
Can't you do a nested query like this?
[SELECT Id, Name, Phone, (SELECT Id, Name, Amount FROM Opportunities) FROM Account]

Rathna DeshmukhRathna Deshmukh
hi it didnt work.I tried this nested query to fetch data from Opportunity and Account in one query call "select id,name,(select name from opportunity) from Account".

I am getting below error:
Didn't understand relationship 'opportunity' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

Please help and give me a sample query on how to fetch data from Account and Opportunity object in single query call.I dont want to make 2 query calls one for Acocunt and one for Opportunity.

Thanks in advance!!