+ Start a Discussion
lovetolearnlovetolearn 

Getting values from an inner join

Hi, 

 

I have the following SOQL query: 

 

Select Id, AccountID, (Select Id, CreatedDate From Tasks ORDER BY CreatedDate DESC LIMIT 1) From Case c

The goal is to returns the Created Date and the ID and all of the tasks that are associated with the Case. I was wondering how do I get the Id value of the Task that is returned by this query?

sfdcfoxsfdcfox

You'll access it through Tasks:

 

case[] cases = [select id,(select id, createddate from tasks order by createddate desc limit 1) from case];
for( case record : cases ) {
  if( record.tasks.isempty( ) ) {
    continue;
  }
  // record.tasks[0] contains your task record.
}