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
SR02SR02 

Child Master relation ship problem

hi,

 

i am new to SOQL. Please help me with this problem.

 

I have created two object Depts(Parent -Master) and Emp(child) and the common fld is deptid__c

 

I am trying to use below query in my code to retrieve values.

 

select name,empname__c,empid__c,deptid__c from emp__c  where deptid__c in(select did__c from dept__c where did__c='D-0002'

 

but it is giving me the error "System.QueryException: semi join sub selects can only query id fields, cannot use: 'did__c'"

 

I tried using below

 

select name,empname__c,empid__c,deptid__c from emp__c  where deptid__c = 'D-0002'

 

which gave me error System.QueryException: invalid ID field: D-0002

 

how to resolve this .

please suggest me

select name,empname__c,empid__c,deptid__c from emp__c  where deptid__c in(select did__c from dept__c where did__c='D-0002')
Shashikant SharmaShashikant Sharma

Hi,

 

Could you tell me what is the type of the field did__c , if it is lookup or master-detail (Reference Field) then it can not be filtered with a text.

 


 

 

SR02SR02

Yes.. it is text...in that case how can I achieve it?? any idea?