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”.

How to Write SOQL Statements

How to Write SOQL Statements

We can fetch both Custom fields and Standards fields in standard objects.

  • SELECT name, id, Active__c FROM Account.
How to Write SOQL Statements

How to Write SOQL Statements

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.
How to Write SOQL Statements

How to Write SOQL Statements

From above example student is the custom object so we have given name asstudent__c and the custom fields called s1__c, s2__c, s3__c andcountry__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.

  • Id
  • IsDeleted
  • CreatedById.
  • CreatedDate.
  • LastModifiedById.
  • LastModifiedDate.
  • SystemModstamp.

Let us see another example to fetch data called first name and last name from standard object called User.

  • SELECT Firstname, Lastname FROM User
How to Write SOQL Statements

How to Write SOQL Statements

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.