“Workbench” is a powerful tool of Salesforce, which offers many ways to administrators and developers to obtain data about your organization using Force.com APIs.
To use Workbench follow the Steps
- Navigate to https://workbench.developerforce.com/login.php.
- In the Environment field select Production from the list, in the API version select the latest API version (ex. 41.0) from the API Version drop-down menu, and accept the terms of service, and click on Login with Salesforce button.
- In the Next screen, enter your login credentials and then click on login button.
- In the Next screen after login, if you are not selected the Query method then move to the top menu bar and select the Queries, a drop-down menu will be open, select the option SOQL Query, and select Account in the Object field. And after click on Select button.Notice that you are chosen an object and not a table. Data is persisted inside of objects, in the other word object is known as sObjects, as in Salesforce Objects.
- Now in the Next screen, to select the fields, hold down the Ctrl key and select AccountNumber, Name, Phone, and Type from the list of Fields. After selecting the object and fields, you will see the SOQL query is generated for you in the text box. It looks like the following:
SELECT AccountNumber,Name,Phone,Type FROM Account
Now, click on Query button to see the results, and results will return as a list.
[Screenshot]
Filtering Your Results
SOQL provides SELECT, FROM and WHERE clauses, but the WHERE clause is optional. A good developer always having to need to include a WHERE clause for almost every query he writes. To filter the records select Name in Sort results by: field, after you will see your filter query looks like this:
SELECT AccountNumber,Name,Phone,Type FROM Account ORDER BY Name ASC NULLS FIRST
[Screenshot]
Using Operator
If you want to use LIKE clause, move to the next field of Filter results by: and click the arrow in the drop-down box for a list of possible operators. Here select contains from the list, and enter “United” text in the next text field.
After following the steps the constructed query looks like this:
SELECT AccountNumber,Name,Phone,Type FROM Account WHERE Name LIKE '%United%'
ORDER BY Name ASC NULLS FIRST
[NOTE: In the above query notice that a wildcards character (%) is using especially leading and trailing wildcards, we didn’t consider it as good practice.]