+ Start a Discussion
DivyaReddyDivyaReddy 

semi join sub selects can only query id fields

HI,

I wrote a controller for generating Mail for that i used query in query concept but error is hitting to that .

 

Error : semi join sub selects can only query id fields, cannot use: 'name' at line 10 column 3 

 

public class Controller
{
 
public List<Account> ac {get; set;}
public List<Point__c> p {get; set;}
public string id {get; set;}
public Controller()
{
p=[Select id,name,E_Mail_Id__c,Account__r.name from Point__c where id IN (Select name from Account where id=:id)];
}
}

 

 Can u please help on this.

Ankit AroraAnkit Arora

Error is self explanatory. You are using inner query in where clause to get the list of ids but you are fetching the name.

 

You should fetch the Point__c from account in query like this :

 

Select Point__c from Account where id=:id

 Please replace the "Point__c" with the field API name of relationship of point on Account. Also make sure you have some Account id in :

 

public string id {get; set;}

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

DivyaReddyDivyaReddy

HI

Thank q for ur reply

 

p=[Select id,name from Account where id IN (Select Account__r.name from point__c where id=:id)];

I kept like this but i am getting error as 

 

" The inner select field 'Account__r.name' cannot have more than one level of relationships " 

 

Can u help on this.