Salesforce Object Query Language is used to query that records from the database.com based on the requirement.
There are 2 types of SOQL Statements:
The Static SOQL Statement is written in  (Array Brackets)
These statements are similar to IINQ (Ion Integrated Query)
String search for =’Jones’;
Contact contacts=[select testfield__c, FirstName, LastName from Contact Where Last Name=:search for];
It is used to refer to the creation of a SOQL string at run time with Apex code.
Dynamic SOQL enables you to create a more flexible application.
To create Dynamic SOQL query at run time use Database.Query() method, in one of the following ways.
Return a single sObjects when the query returns a single record.
sObjects s = Database. Query(String_limit_l);
Return a list of sObjects when the query returns more than a single record.
Example 1:- Queries
String myTestString = ‘TestName’;
List List= Database.Query(SELECT Id FROM MyCustomObject__c WHERE Name = :myTestString);
Example 2:- Queries
String resolvedfield L = myvariable.field__c;
List L = Database.Query(‘SELECT Id FROM myCustomObject__c WHERE field__c = ‘+resolvedfield_L);