I am trying to do nested query but getting error while saving it. Contact and opprotunity have lookup to account. So I am trying to build a nested soql using this. But getting an error while saving Error :
Error: Compile Error: Didn't understand relationship 'Opportunity' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 7 column 19
My code :
public class nestedSoql{
public List<Account> accLst = new List<Account>();
public List<Account> accountChildInformation(){
accLst = [SELECT Name,
(SELECT Name
FROM Contacts
LIMIT 1),
(SELECT Name
FROM Opportunity
LIMIT 1)
FROM Account
WHERE Name != null];
return accLst ;
}
}
Can anyone help me to fix this issue.