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
jaxdmasterjaxdmaster 

SOQL

Hi all,

 

Why below statement is working.

 

Map<Id,Account> mp = new Map<Id,Account>([select name from Account]);

System.debug(mp);

 

I am not selecting Id although code work fine. How is it working?

bob_buzzardbob_buzzard

The id comes through automatically when you carry out a SOQL statement.  Took me by surprise the first time it happened too!

SFDC_LearnerSFDC_Learner

select name from Account is nothing but

Select Id,name from Account.

 

Because the Id will automatically comes with your selected field values.