+ Start a Discussion
sss pppsss ppp 

What is use of using =: symbol please explain with example?

NagendraNagendra (Salesforce Developers) 
Hi Shakambhari,

Please check with below post from the forums community which has clear explanation. Hope this helps.

Please mark this as solved if the information helps so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Best Regards,
Nagendra.
Akshay_DhimanAkshay_Dhiman
Hi Shakambhari,

=: symbol is used inside the SOQL query to comapre a condition with an external object/variable that already define.
Here is the example :
public void accRecords(){

 String userName = 'Amit';

// List get all records with name is Amit

 List<Account> accountRecords = [SELECT name,BillingCity,Phone FROM account where name =: userName ];
 if(accountRecords.size() > 0){
  System.debug('Records are here');
 }
 else {
  System.debug('No Record Found');
 }
}
Let me know if this helps you.

Regards,
 Akshay
Lokesh KumarLokesh Kumar
HI,

use ":" bind variable for access variable in query like

String MyName = 'vasu';
List<Contact> ListOfName = [SELECT FirstName, LastName FROM Contact WHERE FirstName =  : MyName];

use "=" operator is simple Equal operator in query like-:

List<Contact> ListOfName = [SELECT FirstName, LastName FROM Contact WHERE FirstName =  'Patil'];
[give contact list where firstName = (equal) Patil]

Thanks !
Sree SalesforceSree Salesforce
HI ,
":"  :- symbol represents  bind variable in query
"=" :-   if we give eqval with name in single quotation. we dont need ":" this variable
List<Contact> ListOfName = [SELECT FirstName, LastName FROM Contact WHERE FirstName =  'sree'];

"=:"  :-  If we mention the name in string . we have to bind it in query . we need ": " this symbol.
String name = 'sree';
List<Contact> ListOfName = [SELECT FirstName, LastName FROM Contact WHERE FirstName = :  name];

i hope  it helps you
Let me inform if it helps you
Thanks