+ Start a Discussion
NagShaNagSha 

Didn't understand relationship 't.Test__r a' in FROM part of query call.

i have two custom objects parent: test,child:Application

 

i want to send all test object fields for that specific application.,

 

The query i have

 

lsttest =[Select (Select a.English_Writing_Score__c,a.English_Score__c,a.Math_Score__c,a.Reading_Score__c,a.Science_Score__c,a.Composite_Score__c,a.exportSequence__c,a.Other_Score__c,a.SAT_II_Subject__c,a.SAT_II_Subject_Score__c,a.TOEFL_Speaking_Comprehension__c,a.TOEFL_Total_Score__c,a.TOEFL_Writing_Comprehension__c From t.Test__r a) from Application__c t Where Id In :lstids];

 

 

salvatoreovlassalvatoreovlas

the test__r is how it's called on apex code the test__c lookup field on your application__c object.

basically this query is taking for every application the related test.

 

 

NagShaNagSha

Hi.,

 

To be clear.,

 

I have a application field in test object that has lookup relation to application.,

 

yes i need to query all the test scores available for that application., 

salvatoreovlassalvatoreovlas
if you query like that it's going to throw an error please refer to soql queries best practises . http://wiki.developerforce.com/page/Apex_Code_Best_Practices you will find a good example of account with contacts! mark it as a solution if it helps!
NagShaNagSha

i tried doing that way but still has the error.,

 

Here is simple objects to get point which i am missing.,

 

public class test1{
public static void samplemethod(list<id> lstcust){
List<Sample1__c> sam1 = new List<sample1__C>();
sam1 = [Select (select city__c,number__c from a.test__r) from Sample1__C a where id in: lstcust ];
System.debug('================print========'+sam1);
}
}

salvatoreovlassalvatoreovlas

ok if so...it seems that you dont need any field from sam 1 so why dont you try  just to query like this:

public class test1{
public static void samplemethod(list<id> lstcust){
List<Sample1__c> sam1 = new List<sample1__C>();
sam1 = [select city__c,number__c from Sample1__C a where id in: lstcust ];
System.debug('================print========'+sam1);
}
}

salvatoreovlassalvatoreovlas

and as I told you using the __r like that will throw an exception.......

lsttest =[Select a.English_Writing_Score__c,a.English_Score__c,a.Math_Score__c,a.Reading_Score__c,a.Science_Score__c,a.Composite_Score__c,a.exportSequence__c,a.Other_Score__c,a.SAT_II_Subject__c,a.SAT_II_Subject_Score__c,a.TOEFL_Speaking_Comprehension__c,a.TOEFL_Total_Score__c,a.TOEFL_Writing_Comprehension__c  from Application__c t Where Id In :lstids];

 

 

NagShaNagSha

contact---> account;test----->sample1

 

i need to send all thefields of tests associated with sample1 object (like all contacts for account)

NagShaNagSha

problem solved.,

 

used eclipse ide to grab them..,

salvatoreovlassalvatoreovlas
nice for you. :D