You use :
when you're actually binding a variable
:
String myString = 'Testing Account';
List<Account> lstAccount1 = [Select id, Name from Account where Name =:myString limit 10];
This is useful in cases where you don't know the value of your variable, for an example you call another method to calculate something and then you want to bind the result directly in the query:
String myString = SomeClass.findAccountName();
List<Account> lstAccount1 = [Select id, Name from Account where Name =:myString limit 10];
Also it can be useful when you have some conditional statements which can change the same variable which is ultimately used in a SOQL:
String accountName = '';
if (value == true)
{
accountName = 'Something';
}
else
{
accountName = 'Something Else';
}
List<Account> lstAccount1 = [Select id, Name from Account where Name =:accountName limit 10];
And so forth...
Hope that makes things more clear.