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, 9 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

    Getting Into Salesforce

    Getting Into Salesforce? Tips and Tricks You Need to Get your Hands on!

    Blog in Salesforce Training, Salesforce Tutorial

    Are you considering getting into Salesforce? Maybe you are thinking of a new career path, your work is migrating to Salesforce, or you just want…

    Change Management, Getting into Salesforce, Hands-on Experience, Instructor-led Class, learn salesforce
    Stimulus Consulting Aug 30, 2022
    2,831  Views

    Salesforce Automation with Process Builder

    Blog in Salesforce Tools

    Following our previous article on automation tools, this article covers automation using the Process Builder tool in more detail. Process Builder is the newest Salesforce automation tool…

    Business Process, Flow, Process Builder, Salesforce Apex, Salesforce Automation
    KeyNode Apr 12, 2019
    7,555  Views
    The Healthcare Agent Deploying Agentforce Sales for Medical Device and Pharma Pipeline Management

    The Healthcare Agent: Deploying Agentforce Sales for Medical Device and Pharma Pipeline Management

    Blog in Salesforce

    Life sciences commercial teams operate in a highly regulated environment where buying cycles are long, stakeholder groups are complex, and disconnected data can slow execution.…

    Salesforce Agentforce, Salesforce Agentforce Sales
    James Jul 13, 2026
    467  Views

    Popular Salesforce Videos

    Future Methods | Asynchronous Apex | Salesforce Tutorial

    Future Methods | Asynchronous Apex | Salesforce Tutorial

    Video in Salesforce Apex

    Asynchronous Apex 1. Future Methods 2. Making callout using future method 3.Avoiding Mixed Dml using Future Method 4. Why sObjects and objects cannot pass as…

    Salesforce Training, Salesforce Tutorial, Salesforce Apex, Salesforce Video, Salesforce Learning
    kanika Jun 16, 2021
    2,426  Views
    Salesforce Contact Tracing for Employees Demo

    Salesforce Contact Tracing for Employees Demo

    Video in Others, Salesforce Stories

    As businesses gradually reopen after worldwide closures, many people feel concerned about the second spike in COVID-19 cases. To ensure public safety, local officials have…

    salesforce, Salesforce Video, Reopening, COVID-19, Businesses
    Nauman Jun 30, 2020
    1,874  Views
    Salesforce Flow Best Practices: Salesforce Flow Design Patterns

    Salesforce Flow Best Practices: Salesforce Flow Design Patterns

    Video in Salesforce Apex

    Salesforce Flow Design Patterns from Fundamentals to Mastery. In this session, we will talk about the top 10 Salesforce Flow best practices. We will talk…

    Salesforce Training, Salesforce Tutorial, salesforce, Salesforce Flow, Salesforce Video
    Prafull Dec 7, 2021
    5,121  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.