Learn how to write SOQL query in visualforce in salesforce
First we need to understand what is SOQL query afterwards we can take few examples to explain. We use SOQL query to search salesforce data for specific information. It is similar to the 'select' statement which we can widely used in SQL, but this will specially for only salesforce. You can write and execute a SOQL query in Apex code or in the salesforce Developer Console’s Query Editor. Before we start writing and executing queries, we need some data in salesforce org that we need to search. We can add any details which we need to search or that information is already stored into our database.
With SOQL, you can construct simple but powerful query strings in the following environments: -In the query string parameter in the query() call -In apex statements -In visualforce controllers and getter methods -In the schema explorer of the force dot com IDE
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.









