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
Ad_InfosysAd_Infosys 

Error in the Relationship query.

I have a query that has to extract data from objects in relationship.
 
I am geeting error in the.
 
select (select opportunitycontactrole.contact.best_contact_time__c from opportunity.opportunitycontactroles),opportunity.of_pending_stips__c,opportunity.closing_state__c,opportunity.stagename,opportunity.age__c,opportunity.closedate,opportunity.offer__c from task where owneradentid__c='0'
 
 
Can anyone help me correct.
werewolfwerewolf
That is one seriously messed up query.  What are you trying to do?  There are numerous problems here:

- OpportunityContactRole has no s at the end.
- Are you trying to select this from Task or from Opportunity?
- You are trying to use aliases you never defined.
Ad_InfosysAd_Infosys

If I want to access opportunity field from the task associated to it.

I want to access the opportunity details for evry open task.

Select what.owneradentid__c from task where id='..';

owneradentid__c is a field inside opportunity.

This doesnt work. Requirement is to do this in 1 query. I can do this in 2 queries but for several tasks I will hit my governor limit for number of SOQL.

If I use sets, then only unique records in opprtunity are returned.

I want exhaustive list of all tasks, related opportunites. This will be sent as it is to the client application.

Nazeer AhamedNazeer Ahamed

Just I want to suggest you to use - Force.com IDE (Eclipse) or Apex explorer. Where you can buid your queries very easily and view results.