function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rajat Bhatt 4Rajat Bhatt 4 

How to retrieve account name from id using SOQL

Hi, I am new to salesforce and i am facing a problem in retrieving an account name.
I have a String which contains the account id , and i want to fetch the account name  using SOQL so that i can store it in the field?

Thanks in advance.
Best Answer chosen by Rajat Bhatt 4
Raj VakatiRaj Vakati
You need to user SOSL libe below 

Account acc  = [Select Id ,Name from Account where id=:yourIDString ] 

Or

Account acc  = [Select Id ,Name from Account where id='record id '] ; 
 

All Answers

Raj VakatiRaj Vakati
You need to user SOSL libe below 

Account acc  = [Select Id ,Name from Account where id=:yourIDString ] 

Or

Account acc  = [Select Id ,Name from Account where id='record id '] ; 
 
This was selected as the best answer
Rajat Bhatt 4Rajat Bhatt 4
Thanks Raj