+ Start a Discussion
ifthikar Ahmed 1ifthikar Ahmed 1 

what is the mistake

i am new to salesforce getting parssing error what is wrongwith my query 

select id,name (select id, name from Contacts) from Account where Name ='test6'
Best Answer chosen by ifthikar Ahmed 1
Deepali KulshresthaDeepali Kulshrestha
Hi ifthikar,

Greetings to you!

You have to use a comma to separate each field you want to access. And this soql query must be in the square bracket. And for the best practice, you should use the list for assigning the result of the soql.

List<Account>  ac = [select id,name, (select id, name from Contacts) from Account where Name ='test6'];

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
 

All Answers

Team NubesEliteTeam NubesElite
Hi Ifthikar,
You should use a comma after name in first query, Please try this code
SELECT Id,Name, (SELECT Id, Name FROM Contacts) FROM Account WHERE Name ='test6'
Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this assolution if your problem resolved.
 
Deepali KulshresthaDeepali Kulshrestha
Hi ifthikar,

Greetings to you!

You have to use a comma to separate each field you want to access. And this soql query must be in the square bracket. And for the best practice, you should use the list for assigning the result of the soql.

List<Account>  ac = [select id,name, (select id, name from Contacts) from Account where Name ='test6'];

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
 
This was selected as the best answer