OR, AND and WHERE Clause:

Select Student_name from student__c where couse_opted__c = ‘Salesforce Admin’;

Select Student_name from student__c where couse_opted__c = ‘Salesforce Admin and App Builder’ OR couse_opted__c = ‘Salesforce Developer’;

Select Student_name from student__c where couse_opted__c = ‘Salesforce Admin and App Builder’ OR graduated__c = false;

Example:

public class soql

{

public static void main()

{

List<Account> accList = [Select Name, NumberOfEmployees from account];
        for(integer i=0; i<accList.size(); i++)
        {
        System.debug(accList[i].numberOfEmployees);
        }
       
        // *** FOR EACH LOOP ***
       
        for(Account a:acclist)
        {
        System.debug(‘Acc Name = ‘+a.Name+’NumOfEmp = ‘+a.numberOfEmployees);
        }

}

}

Note: It is mandatory to mention the field in the SOQL query which you want to access in the Apex Code.

Note: Comparison of strings are case sensitive using ’=’ operator in soql.

Our Recent Blog

Share This Post