Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • 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
  • Marketplace
  • Advertise With Us
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • 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
    • Marketplace
    • Advertise With Us
    • 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 7 years, 11 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]);

    • 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

    application solution

    Popular Salesforce Blogs

    Marketing Cloud Overview in 2024

    Blog in Others

    This article explores Salesforce Marketing Cloud, the exclusive Einstein-powered marketing platform built on the world's most trusted CRM. Designed to foster lasting customer relationships, it…

    CRM, Customer Journey, Customer Relationships, Dashboard, Data Integration
    Vimera | Andersen Feb 8, 2024
    1,142  Views
    Salesforce Lightning

    Why Should You Consider Migrating To Salesforce Lightning In 2022?

    Blog in Lightning

    Salesforce has been in the industry for over two decades and has already carved its niche in the market. The CRM platform has been consistent…

    app development, Applications, Aura Framework, Business Goals, Business Process
    Manish Pandey Jan 27, 2022
    3,496  Views
    Salesforce Einstein Analytics

    When you Need to Switch to Salesforce Einstein Analytics

    Blog in Salesforce Einstein

    Salesforce Einstein Analytics is the cloud-based totally analytical tool that allows Salesforce customers to understand, combine, and visualize data coming from different places, which include…

    Artificial Intelligence, Automate Real-time Facts, Automobile-saving, Business Enterprise, Calls
    Anjali Jun 9, 2021
    3,436  Views

    Popular Salesforce Videos

    Salesforce Communities: 5 Powerful Ways to Drive Growth

    Salesforce Communities: 5 Powerful Ways to Drive Growth

    Video in Salesforce Communities

    Salesforce Communities are brand spaces designed specifically for Salesforce customers to connect with the community outside their org (i.e., employees, partners, and customers) and collaborate…

    Salesforce Training, Salesforce Tutorial, Salesforce Video, Salesforce Learning, Salesforce Customers
    Nauman May 11, 2022
    5,128  Views
    CPQ B2B Commerce Cloud Connector | Salesforce Tutorial

    CPQ B2B Commerce Cloud Connector | Salesforce Tutorial

    Video in Salesforce Products, Salesforce Training

    In these difficult economic times, businesses are looking for ways to improve efficiency and reduce the cost of doing business. More than ever, efficiency and…

    Salesforce Training, Salesforce Tutorial, salesforce, CPQ, Salesforce Video
    Algoworks Nov 16, 2021
    2,661  Views
    Happy 2021 to the Salesforce Ohana

    Happy 2021 to the Salesforce Ohana

    Video in Salesforce Stories

    As 2020 comes to a close, the challenges of the past year give way to hopes of a new year full of love, cheer, &…

    Salesforce Community, Salesforce Ohana, Salesforce Guide, Salesforce Video, Salesforce Help
    Pooja Jan 7, 2021
    1,494  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

    © 2025 - 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®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.