function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BNB BaluBNB Balu 

What is diff between Static soql and Dynamic soql queries?give some examples.

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Balu,

Static SOQL:- Dynamic SOQL:-
  • Dynamic SOQL means your value and query is not fixed. It depend on user Input like below
  •  String StrName ='xyz';
  •  List<Account> lstAccount = [select id,name from account where name =:StrName ];

NOTE : a- here value of StrName you can take from user( by VF page)

Dynamic SOQL refers to the creation of an SOQL string at runtime with Apex code. Dynamic SOQL enables you to create more flexible applications
1 List<sObject> sobjList = Database.query(string);

You can see dynamic SOQL code in below blog
Please mark it as best Answer if the information is informative.

Best Regards
Rahul Kumar