You are using inner query in where clause to get the list of ids but you are fetching the name. So , Nested Query doesnt work in this scenario.
I did this to achieve above:-
List<Contact> myAccList = [ SELECT id,Name FROM Account WHERE Type IN('Prospects','Qualified')]; // You Inner Query Part
if(myAccList.size()>0){
List<Contact> Con = [SELECT id , FirstName , LastName FROM Contact WHERE ID =: myAcclist.id ]; // You External Query Part , I havent tested this in DEVELOPER CONSOLE, mite me wrong over Syntax
}
Important :
Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Hi,
Important :
Click on the Star Icon aside if this post provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.
Thank You
You should create a list sepearately : -
List<String> Listofsubjects = new List<String>{'Hindi', 'Maths' };
SELECT First_Name__c, Name From Student__c WHERE Class__r.Name IN (SELECT Class__r.Name FROM Teaches__c WHERE Subject__c IN: Listofsubjects ))