You need to sign in to do that
Don't have an account?
Abdul Mujeeb Shaik
this is error , but i must query from Account Sobj Only.
Parent to child SOQL Query
how to query all the Contacts,opportunity and opportunitylineitems from Account Object.
I can able to query only contacts and opportunities from Account object.
but i want OpportunitylineItems also in a single query to display in table formats , cany any one help me
This is how i am querying,
SELECT Name,(SELECT name,OpportunityLineItems.name from Opportunities) FROM Account
this is error , but i must query from Account Sobj Only.
If it is allowed then it will be in this format. SELECT Name,(SELECT name, (select name from OpportunityLineItems) from Opportunities) FROM Account. but currentlty only one level can be selected from the root.
Go with Two SOQLS.
- One with contacts and opportunities from Account object
- Second with Opportunities and OpportunityLineItems. Map<Id, Opportunity> oppList = new Map<Id, Opportunity>([SELECT name, (select name from OpportunityLineItems) from Opportunities where accounid in:idList]);
- Iterated the first query and set the OpportunityLineItems in each opportunity by getting it from Map
opp.OpportunityLineItems = map.get(opp.id).OpportunityLineItems;
its like bit advanced ,
can you please help be out how to achieve this , @balaji r
a sample of single record with single columns in each object , please,...