Toggle Side Panel

  • Blogs
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Blogs
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Contact Us
    • Discussions
    Close search

    Activity › Forums › Salesforce® Discussions › Is it possible to run a SOQL Query and get a MAP returned?

    Tagged: Account, Apex Map, Salesforce Apex, Salesforce Query, SOQL

    • Salesforce® Discussions

      Is it possible to run a SOQL Query and get a MAP returned?

      Posted by Tanu on August 5, 2016 at 1:16 PM

      Is it possible to run a SOQL Query and get a MAP returned?

      Ajay Prakash replied 8 years, 7 months ago 3 Members · 2 Replies
      • Account
      • Apex Map
      • Salesforce Apex
      • Salesforce Query
      • SOQL
    • 2 Replies
    • Himanshu

      Member
      August 5, 2016 at 1:32 PM

      Hi Tanu,You can use the below query

      Map m = new Map([SELECT Id, Name FROM Account]);

    • [adinserter block='9']
    • Ajay Prakash

      Member
      January 13, 2018 at 3:16 PM

      Hi Tanu,

      Yes, You can run SOQL query and return into a map. You can refer below code it will return a map of Account id vs Account map-

      Map<id,Account> mapOfAccountIdVsAccount = new Map<Id,Account>([SELECT Id, Name FROM Account]);
      system.debug('mapOfAccountIdVsAccount::'+mapOfAccountIdVsAccount);

      Thanks.

       

    Log In to reply.

    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me
    • Public
    • All Members
    • My Connections
    • Only Me

    Popular Salesforce Blogs

    Salesforce Consultation Partner

    How to Choose the Right Salesforce Consultation Partner for Your Business?

    Blog in Salesforce Consultant

    Salesforce consultation partners help businesses establish CRMs and other tech tools, so they perform seamlessly. The primary role here is to collect and maintain databases…

    Business, Business Consultants, Business Productivity, Businesses Measure, Client Satisfaction
    Melonleaf Sep 13, 2022
    2,392  Views
    Salesforce Best Practices

    Learn About These Salesforce Best Practices

    Blog in Salesforce

    Defining best practices in Salesforce is never going to be an easy task, as Salesforce itself contains so many things, from developing a code to…

    AppExchange, Application, Best Practices, Best Practices in Salesforce, Business Team
    kishan Nov 9, 2021
    3,449  Views

    Salesforce Classic to Lightning Migration: Benefits and Best Practices

    Blog in Lightning

    Salesforce is a comprehensive CRM platform that delivers almost everything needed to manage business operations efficiently. It is a powerful toolset that enables top-level management…

    Automation Capabilities, Back-End Design, Best Practices, Boosted Productivity, Business Operations
    Carol May 29, 2023
    2,064  Views

    Popular Salesforce Videos

    Lightning Component Development - 01 - Basic of Lightning Framework, Component Bundle, App Builder

    Lightning Component Development - 01 - Basic of Lightning Framework, Component Bundle, App Builder

    Video in Lightning

    What is covered in this session? * What is Lightning Component Framework? * Lightning Component Across Salesforce Ecosystem * When to use lightning component? * Where…

    Salesforce Development, Salesforce Apex, salesforce training videos for beginners, Free Salesforce Training, Salesforce Lightning
    Shiv Kumar Sharma May 21, 2018
    3,013  Views
    Salesforce Integration | GET Method - Part 2 | Salesforce

    Salesforce Integration | GET Method - Part 2 | Salesforce

    Video in Salesforce Integration

    Salesforce integration is the process of merging the data and functionality of Salesforce with another application to provide users with a single unified experience. It…

    Salesforce Training, Salesforce Tutorial, Salesforce Integration, Salesforce Lightning, salesforce
    kanika Jun 2, 2022
    2,061  Views
    How Salesforce Industries can be Used on Top of Salesforce?

    How Salesforce Industries can be Used on Top of Salesforce?

    Video in Salesforce Training

    Salesforce Industries offers pre-built solutions on the Salesforce platform that solve the needs of particular industries. Vlocity takes these common requirements and packages them into…

    Salesforce Training, Salesforce Tutorial, Salesforce Development, salesforce, Salesforce Admin
    Cyntexa Nov 18, 2022
    1,542  Views
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.