I want to know LastName and PersonEmail from account. So I made sql like this:

[SELECT AccountNumber, LastName, PersonEmail, Phone, BillingPostalCode FROM Account]

But it doesn't work properly and errors.

No such column 'LastName' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. How can I get LastName from Account Object?


3 Answers 3


Is Person Accounts feature enabled in your salesforce org?

For LastName, PersonEmail and other related fields, ensure field visibility is enabled.

If you are querying person account fields from Account object then put a where clause IsPersonAccount=True in your query.

  • The IsPersonAccount=true is not required, but of course the fields will be null for business accounts. Also, FLS isn't the issue. Person Accounts is not enabled for the org.
    – sfdcfox
    Commented Jun 18, 2017 at 16:20

Person Accounts combine both Contact and Account where some Contact Info is also displayed in the Account Detail page. In a person account, the Contact.Name field is displayed as the Account.Name field. To get a separate FirstName and LastName, you need to query the Contact object.

Your query would need to look more like

[SELECT LastName, Email, Phone, PostalCode, AccountId from Contact]

If you query it from Account, you'd need to do a subquery to get the Contact's LastName.

[SELECT AccountNumber, Phone, BillingPostalCode (SELECT LastName, Email FROM CONTACT) FROM Account] 

You might optionally want to add WHERE clause like: WHERE Account.NAME contains Contact.LastName

  • It's not necessary to query the contact for standard fields.
    – sfdcfox
    Commented Jun 18, 2017 at 16:20
  • @sfdcfox I agree if it's a standard field. That also requires a query to use IsPersonAccount=true. In which case, there are a number of Contact fields that then become available as IsPersonAccount fields that can be queried directly from Account. In either case, the fields will still exist under Contact.
    – crmprogdev
    Commented Jun 18, 2017 at 21:52

If person account is enabled in your Org you will have a record type called 'Person Account' when you try to create a new account.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .