How to Write SOQL Statements : In our Previous Salesforce Tutorial we have learned How to download and Install Force.com Explorer Software to write our first SOQL Statement. In this Salesforce Training Tutorial we are going to learn about How to write our first SOQL statement.
So to execute our SOQL Queries we have to install some tools that executes SOQL statements in Salesforce.com. In our previous Salesforce Training article we have learned How to Download and install Force.com Explorer software. In our next SOQL Salesforce tutorials we use Force.com Explorer software only.
How to Write SOQL Statements ?
In this example we are taking Standard Object called “Account“. Account is a standard object where we store store information about our customers and partners.
- SELECT id, Name FROM Account.
From above SOQL statement we fetching Id and name of the Standard object called “Account”.
We can fetch both Custom fields and Standards fields in standard objects.
- SELECT name, id, Active__c FROM Account.
From above screenshot we have fetched both standard and custom fields from Account object. Custom fields with extension __c.
- SELECT name, s1__c, s2__c, s3__c, country__c FROM student__c.
From above example student is the custom object so we have given name as student__c and the custom fields called s1__c, s2__c, s3__c and country__c. Name field is the Standard field in above example.
In Salesforce.com every object has system fields or standard fields. These system fields have read-only property. List of system fields are.
Let us see another example to fetch data called first name and last name from standard object called User.
- SELECT Firstname, Lastname FROM User
These are the few example of SOQL statement queries. From this Salesforce tutorial we have learned Basic SOQL Statements. We have seen fetching records from Standard objects and Custom object.