You need to sign in to do that
Don't have an account?
praveen venkata
Want to print contact record firstname using parent to child relation query
list<account> acc_list=[select Id,name,Industry,Rating,(select ID,firstname,lastname
from account.contacts) from account where phone='abc122'];
system.debug(acc_list);
for(account a:acc_list)
{
system.debug(contacts.firstname); // ERROR: Field doesnt exists
}
You have to again loop in the contacts list
Each account has a list of contacts, so you loop through them and print.
Regards,
Satish Kumar
Please mark my answer as a solution if it was helpful so it is available to others as a proper solution.
If you felt I went above and beyond, please give me Kudos by clicking on the star icon.