can anyone could have a look and let me know what is wrong with this query?

List projects = [SELECT id, Number_of_Assignments__c, Number_of_billable_assignments__c 
                   FROM Project__c 
                  WHERE id IN (SELECT Project__r.id, isActive__c 
                                 FROM Assignment__c WHERE isActive__c = true)];

It throws this error

"unexpected token: ,"

Project__c Master, Assignment__c Child

I will be very grateful for your assistance

1 Answer 1


I see two things to correct here:

  1. It's not legal to have an untyped List. You need a List<Project__c> projects.
  2. You don't need to (and probably shouldn't) traverse a relationship in your sub-select. Just do WHERE Id IN (SELECT Project__c ...), i.e., use the relationship field directly as your Id column.

The documentation on this is at Semi-Joins and Anti-Joins. There's a lot of power and some interesting facets/restrictions for this type of query.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .