You need to sign in to do that
Don't have an account?

How to structure query to include fields from Account and Lead tables
I can't seem to find any examples where I want to include fields in my query from the Lead table and the related Account table where the ConvertedAccountId matches. I have tried writing queries but nothing is working. Isn't this possible? I can do two queries but I want to only do one and include some fields found in each table.
All Answers
[select name,Room__r.name from Booking__c where id='a0I28000002aQaK']
Room__r.name is the field of the lookUp object in Booking__c.... hope you find ur answer
for (Lead ld : Trigger.new) {
if(ld.isConverted)
{
convertedAccountset .add(ld.ConvertedAccountId);
}
}
if(!convertedAccountset.isEmpty )
{
list<accout> act=[select id , add account field from account where id IN: convertedAccountset ];
}
Example of querying for the account names from leads that were converted into accounts:
The gist is the "Id" in the "ConvertedAccountId" lead field is replaced with ".[account field name]". It can even go a level deeper to get the data for current converted account owner with "ConvertedAccount.OwnerId" becoming "ConvertedAccount.Owner.[owner field name]".
Isn't this possible?
Is there anyway to go from Account to Lead? The example above goes from Lead to Account.