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
Kent GeorgesonKent Georgeson 

Simple Join challenge

I have read the documentation that every points other similar questions to, but for the life of me I just can't get my head around this.

I have a very simple query
Select Id, Department, Email, FirstName, LastName, Phone From Contact
  Where Id IN (Select OwnerId From Case)
That gives me the error "The selected field 'OwnerId' in the subquery and the left operand field in the where expression in the outer query 'Id' should point to the same object type"

I want to return a list of contacts, but our contacts data is massive.  So I want to only return the contacts that are the owners of cases.   Any suggestions?
 
{!pramod_nishane}{!pramod_nishane}
Hi Kent,

As you are querying Contact object (Id start with - 003) and your inner query says that you will return User object (Id start with - 005) OwnerId from Case object.
so this will not work anyways as you are checking contactId against UserId.

According to your requirement you want contact list but those should be owner of cases only.
have you creating your user from contact by enabling 'Enable Partner User' becuse if you are doing same then you can have Contact Lookup in your User object so you can acheive your requirement through that.

Please provide the details for the same.

Thanks,
Pramod Nishane
Salesforce Consultant
Varasi LLC
www.varasi.com
Kent GeorgesonKent Georgeson
That's exactly the info I needed.  I didn't understand that they were actually different object types.   This lead me down the path of understanding the different prefixes and how they reference different objects.   I get it now.   Thank you.