Activity Forums Salesforce® Discussions How can we fetch/retrieve only one contact from account in SOQL Query in Salesforce?

  • Deepanshu Singh

    Member
    January 18, 2020 at 5:09 pm
    set<id> accountids = new set<id>();
    for(Contact con : Trigger.New) {        
         accountids.add(con.AccountId);
    }
    List<account> accList = [ select Name, (select AccountId, firstName, lastName from Contacts where AccountId =: accountids limit 1) from Account ];

     

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos