+ Start a Discussion

Single record fetch

Is there any way in which I can fetch a single record by specifying the primary key?

Thank you.






In salesforce id is a unique identifier. You can retrieve a single record on the basis of id.


Try the below code snippet as reference:

Contact con=[select name from contact where id= ‘id’];


Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 





Thank you very much.


I am completely new to this enviornment.I got what you were trying to say.

This SFQL should work, but I need to fetch the entire record. It that case I can use "Select * from..."

Can you please guide me as to where I should write this query and where do I compile and run it?

Secondly, I think I will need an search button for this action to be performed. Can you provide links or a little guidance on that too?


Thank you once again.Your help is appreciated.






You can use Legacy System Id to fetch complete record, Legacy system is alo a complete unique id.


for ex: select * from "table name" where Legacysystemid = 'IND0123"


Hope this solutions helps u , Mark as solution if this post work.


No you cannot query that way.



You need to specify all the standard and custome fields with comma separated.


ex:[select Id,Name,Phone,Email__c from Account];