You need to sign in to do that
Don't have an account?
JamesSS
self lookup accounts in Account object in soql
How to get the self lookup accounts in Account object in soql?
List <Account> AccountsList = [ SELECT Id,
Name,LastActivityDate
(select Id,Name,Owner.Name,Owner.Alias from ParentAccount)
FROM Account
WHERE ( ParentId = null)
];
In above soql is wrong.. please any one help to get this original soql?
List <Account> AccountsList = [ SELECT Id, Name,LastActivityDate (select Id,Name,Owner.Name,Owner.Alias from CHILDRELATIONSHIPNAME__r ) FROM Account WHERE id = : ACCOUNTID ];
CHILDRELATIONSHIPNAME is a name which you can get from custom field ( lookup of Account).
in this case you have id of account ACCOUNTID
Thanks sandeep.
But i need to query the all parent accounts without ACCOUNTID.Is it possible?
Hello,
Use this instead:
select Id, Name, Owner.Name, Owner.Alias
from Account
where Parent.Id = null
Regards
Could you give kudos to my reply (click the star), if it helped you?
Thanks,
Hugo