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

    Explore How DemandBlue’s Revenue Cloud Offering Could Enhance Your Business Model

    Blog in Salesforce Products

    Does your business lack absolute transparency across your sales cycle, finance operations, and revenue channels? Maybe it’s time to improve your game. If you are…

    B2B Commerce, Bbusiness Model, billing, Billing Process, Billing Tool
    LevelShift (formerly DemandBlue) Nov 17, 2021
    2,041  Views

    How to Make Your Fundraising Campaigns More Effective Through Salesforce

    Blog in Salesforce, Salesforce Products

    Salesforce has earned its place as one of the most intuitive and comprehensive CRM solutions in the market today that’s been used by many businesses.…

    Application, Business, Business Cards, CRM Framework, CRM Solutions
    Apphienz Jun 9, 2021
    2,090  Views
    What are Apex Triggers?

    What are Apex Triggers in Salesforce? | The Developer Guide

    Blog in Salesforce Apex

    What are Triggers? Apex can be invoked by using triggers. Apex triggers enable you to perform custom actions before or after changes to Salesforce records,…

    Apex Triggers, Assignment Rules, Asynchronous Events, Audit Tables, Auto-Response Rules
    SF Apr 17, 2023
    1,722  Views

    Popular Salesforce Videos

    Scheduled Actions Workflow Rules, Process Builder and Lightning Flow

    Scheduled Actions Workflow Rules, Process Builder and Lightning Flow

    Video in Lightning

    Time-dependent actions are executed at a specific time, such as 10 days before a record's close date. When that specific time passes, the workflow rule…

    Salesforce Lightning, salesforce, Process Builder, Salesforce Video, Salesforce Learning
    Nauman May 19, 2020
    2,676  Views
    How to Subscribe Salesforce Report in Lightning Experience?

    How to Subscribe Salesforce Report in Lightning Experience?

    Video in Lightning

    Subscribe Report : We can configure any Salesforce report to run Daily, Weekly or Monthly as HTML email to your Salesforce org. users. Advantages of…

    Salesforce Reports, Salesforce Lightning, Salesforce Lightning Experience, Salesforce Implementation, Learn Salesforce
    Abhay Feb 26, 2018
    2,047  Views
    Non Technical but Want to Build Career in Salesforce?

    Non Technical but Want to Build Career in Salesforce?

    Video in Salesforce Certifications, Salesforce Training

    In this video Shrey gave the answer of the following questions: 1. What is the next step after doing Certification in Salesforce Administrator? 2. How…

    Salesforce Tutorial, Salesforce Certifications, Salesforce Implementation, salesforce knowledge, Salesforce Learning
    S2 Apr 6, 2022
    1,996  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.