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);
Static SOQL:-
- Static SOQL means you are using some SOQL with any user input or hardcode values like below query
- List<Account> lstAccount = [select id,name from account where name ='Rahul'];
- https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dynamic_soql.htm
Dynamic SOQL:-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