i am new to salesfoce and have query like this
list<account> accList= [select id, name, accountNumber (select id, firtName, LastName, phone from contacts) from account];
now i want to display records of account name in one system.debug and display firstName and phone values in another system.debug i am confusing nested for loop could any help me on this3 answers
Hi Prashanth, You can use the below code snippet:
for(Account acc : accList) {
system.debug(acc.Name);
for(Contact con : acc.Contacts) {
system.debug(con.FirstName);
system.debug(con.Phone);
}
}
Let me know if you need any further help.
Thanks,Abhishek Bansal.