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
dave_mwidave_mwi 

SOQL sub select - checking for subselect equal to NULL

I have the following soql statement:

Select o.Id, (Select ContactId From OpportunityContactRoles) From Opportunity o

However, some of the opportunities don't have contact roles...so this query retrieves all of my opportunities with our without contact roles. I'm using the Force IDE along with the schema browser and this shows up as a two-columned table with one of the columns being an OpportunityContactRole object - titled 'OpportunityContactRoles' and no, trying OpportunityContactRoles != NULL in the main query didn't work.


So my question is, how do I only get the opportunities that only have associated opportunity contact roles?
Ron HessRon Hess
what about this type of query

Code:
Select o.Opportunity.Amount, o.Opportunity.StageName, 
o.Opportunity.Name, o.Opportunity.Id,
o.OpportunityId, o.ContactId From OpportunityContactRole o