
In the Developer Console, click the Query Editor tab. Copy and paste the following into the first box under Query Editor, and then click Execute. SELECT Name,Phone FROM Account
- All of the object's fields display. Select the fields you would like displayed in the result list. ...
- Click the Query button to create and add the SOQL query to the editor.
- Click the Execute button to run the query and see the results.
How do I run a soql query in Salesforce?
Let’s try running the following SOQL example: In the Developer Console, click the Query Editor tab. Copy and paste the following into the first box under Query Editor, and then click Execute. All account records in your org appear in the Query Results section as rows with fields.
How do I run soql queries in the developer console?
In the Developer Console, open the Execute Anonymous window from the Debug menu. Insert the below snippet in the window and click Execute. The Developer Console provides the Query Editor console, which enables you to run your SOQL queries and view results. The Query Editor provides a quick way to inspect the database.
What are the different types of queries in Salesforce?
Other—The query uses optimizations internal to Salesforce. Sharing—The query uses an index based on the user’s sharing rules. If there are sharing rules that limit which records are visible to the current user, those rules can optimize the query. TableScan—The query scans all records for the query object, and doesn’t use an index.
What is the query editor console used for?
The Developer Console provides the Query Editor console, which enables you to run your SOQL queries and view results. The Query Editor provides a quick way to inspect the database.

How do I write a SOQL query in Salesforce Developer Console?
Execute SOQL queries or SOSL searches in the Query Editor panel of the Developer Console.Enter a SOQL query or SOSL search in the Query Editor panel.If you want to query tooling entities instead of data entities, select Use Tooling API.Click Execute.More items...
How do I open the query editor in Salesforce Developer Console?
0:153:47How to Use the Salesforce Developer Console to Run Queries ... - YouTubeYouTubeStart of suggested clipEnd of suggested clipFirst you need to log in in the Salesforce. Or the Dimity for saw and once login under your nameMoreFirst you need to log in in the Salesforce. Or the Dimity for saw and once login under your name thus click on the developer console.
How do I create a query in Salesforce?
To open the queries panel, click an empty space in the dashboard canvas in the dashboard designer. Click Create Query. Click Dataset for a CRM Analytics dataset or Salesforce Direct for a Salesforce object. Select the dataset or Salesforce object that contains the data that you want to include in the query.
How do I enable query in developer console?
Enable and Use the Query Plan ToolIn the Developer Console, click Help | Preferences.Set 'Enable Query Plan' to TRUE.
How do I write a SOQL query in Apex class?
To include SOQL queries within your Apex code, wrap the SOQL statement within square brackets and assign the return value to an array of sObjects. For example, the following retrieves all account records with two fields, Name and Phone, and returns an array of Account sObjects.
How do I run a script in Salesforce Developer Console?
Go to “Developer Console” and click “Query Editor” tab.Click on “Debug” tab.Select ”Open Execute Anonymous Window” option or press CTRL+E.Insert script and click “Execute” button.
Can you write SQL in Salesforce?
You can use SQL to join Salesforce data with product data. In this post, we'll walk through a sample report replicating common Salesforce CRM reporting in SQL, so you can more easily audit, adjust, and extend that analysis. You'll find the queries we outline in this post collected in this sample report.
What is database query in Salesforce?
query in Salesforce allows you to make a dynamic SOQL query at runtime. You can build up a string and then use that as a query string at run time in the database. query statement to make a SOQL call that is determined at run time. In Batch Apex, if you use Database.
How do I run a query in Salesforce inspector?
1:484:25How to Query Data Using Salesforce Inspector - YouTubeYouTubeStart of suggested clipEnd of suggested clipAnd tell you if you're typing in a field that doesn't exist so for example if i just say select id.MoreAnd tell you if you're typing in a field that doesn't exist so for example if i just say select id. Name from product. So first of all notice as i started typing in the object.
How do I use the Query Plan tool in Salesforce?
Inside Salesforce, go to the Setup Menu and launch the Developer Console. By default the Query Plan tool is off so we need to go into the Developer Console Preferences and enable it. From the Preferences Menu, set the Query Plan option to "True" and click Save.
How do I view a Query Plan in Salesforce?
If custom indexes are available for your organization, use query plans to help you decide when to request a custom index from Salesforce Support. To enable the Query Plan button in the Query Editor, click Help | Preferences, set Enable Query Plan to true , and then click Save.
What is dynamic SOQL in Salesforce?
Dynamic SOQL refers to the creation of a SOQL string at run time with Apex code. Dynamic SOQL enables you to create more flexible applications. For example, you can create a search based on input from an end user or update records with varying field names. To create a dynamic SOQL query at run time, use the Database.
How to read Salesforce records?
To read a record from Salesforce, you must write a query. Salesforce provides the Salesforce Object Query Language, or SOQL in short, that you can use to read saved records. SOQL is similar to the standard SQL language but is customized for the Lightning Platform.
What is SOQL in Salesforce?
Salesforce provides the Salesforce Object Query Language, or SOQL in short, that you can use to read saved records. SOQL is similar to the standard SQL language but is customized for the Lightning Platform. Because Apex has direct access to Salesforce records that are stored in the database, you can embed SOQL queries in your Apex code ...
What is the developer console?
The Developer Console provides the Query Editor console, which enables you to run your SOQL queries and view results. The Query Editor provides a quick way to inspect the database. It is a good way to test your SOQL queries before adding them to your Apex code. When you use the Query Editor, you must supply only the SOQL statement without the Apex code that surrounds it.
What to do if you use Trailhead in a different language?
If you use Trailhead in a language other than English, make sure that your hands-on org is set to the same language as the challenge instructions. Otherwise you may run into issues passing this challenge. Want to find out more about using hands-on orgs on Trailhead? Check out Trailhead Playground Management.
How to include SOQL query in Apex?
To include SOQL queries within your Apex code, wrap the SOQL statement within square brackets and assign the return value to an array of sObjects. For example, the following retrieves all account records with two fields, Name and Phone, and returns an array of Account sObjects.
What is SOQL for loop?
SOQL for loops iterate over all of the sObject records returned by a SOQL query. The syntax of a SOQL for loop is either:
Why use sobject list format in SOQL?
It is preferable to use the sObject list format of the SOQL for loop as the loop executes once for each batch of 200 sObjects. Doing so enables you to work on batches of records and perform DML operations in batch, which helps avoid reaching governor limits.
How to use SOQL?
When to Use SOQL 1 Retrieve data from a single object or from multiple objects that are related to one another. 2 Count the number of records that meet specified criteria. 3 Sort results as part of the query. 4 Retrieve data from number, date, or checkbox fields.
What is SOQL in SQL?
Similar to the SELECT command in Structured Query Language (SQL), SOQL allows you to specify the source object (such as Account), a list of fields to retrieve, and conditions for selecting rows in the source object.
Can SOQL be used with archived data?
With archived data and big objects, you can use only some SOQL features. For more information, see SOQL with Big Objects.
Can SOQL be used to perform arbitrary join operations?
For example, you can’t use SOQL to perform arbitrary join operations, use wildcards in field lists, or use calculation expressions. SOQL uses the SELECT statement combined with filtering statements to return sets of data, which can optionally be ordered: SELECT one or more fields. FROM an object.
How to get performance feedback in SOQL?
A SOQL query to get performance feedback. Use explain instead of q to get a response that details how Salesforce processes your query. Use this feedback to further optimize your queries. To get feedback on how Salesforce processes a report or list view, use a report or list view ID in place of the query string.
How to create a valid URI in SOQL?
A SOQL query. To create a valid URI, replace spaces with a plus sign + in the query string. For example: SELECT+Name+FROM+MyObject. If the SOQL query string is invalid, a MALFORMED_QUERY response is returned.
What is index in Salesforce?
Index—The query uses an index on the query object. Other—The query uses optimizations internal to Salesforce. Sharing—The query uses an index based on the user’s sharing rules. If there are sharing rules that limit which records are visible to the current user, those rules can optimize the query.
What happens if SOQL query string is invalid?
If the SOQL query string is invalid, a MALFORMED_QUERY response is returned. If the report or list view ID is invalid, an INVALID_ID response is returned.
How many records can be returned in SOQL?
When a SOQL query is executed, up to 2,000 records can be returned at a time in a synchronous request. If the number of results exceeds this limit, the response contains only the first set of results and a query identifier, contained in the response’s nextRecordsUrl field. The identifier can be used in another request to retrieve the next batch of records.
What version of API is explain parameter?
The explain parameter is available in API version 30.0 and later.
Can you increase the batch size of a SOQL query?
You can run a query and increase the batch size of the results using the query identifier. For more information, see Execute a SOQL Query.
Reasons to use the Query Plan Tool
Use this tool to check the Query Plan for any SOQL queries that execute slowly. It will provide you with insight on the different plans and should you have some of the filters indexed, provide the cost of using the index compared to a full table scan.
What does it all mean?
The Query Plan Tool will show a list of available plans that our Query Optimizer can use for the query provided and will be arranged by cost ascending.
Indexed field does not appear in the list of plans
If the query you provided contains an Indexed field in the filters, the plan will be shown for that field only if you are using a supported operation against that field.
Examples and how to interpret Query Plan results
The following examples uses 2 indexed fields. A checkbox ( InActiveAcc__c) and a Picklist ( Account_Hierarchy__c) on the Account sObject.
What does queryall do?
QueryAll () - Retrieves data from specified objects, whether or not they have been deleted.
Can you use wildcards in Salesforce?
You cannot use wildcards in salesforce querys. You will need to extract the field names and generate a SOQL that includes all the fields. Alternatively, you can use the developer console to generate the query and it will give you all the fields and use that. August 25, 2014. ·.
