SOQL is the query language in Salesforce, whose full name is Salesforce Object query Language.
Literally, this language is an object-based query language.
In Salesforce, we can build objects, and Salesforce has its own objects, which can be abstracted as a data Table for these objects.
Each object has the properties of the field, and Soql is querying fields under individual objects.
The basic syntax of SOQL is not very different from the SQL we know well, for example:
list<account> accounts = [select ID from Account];
Normally in Apex code, SOQL is unloaded [], and SOQL returns list<object>.
The example is to query the ID of all account under this object.
In SOQL, there is no join in this notation, in Salesforce, object and object have a relationship for lookup relationships, that is, a one-to-many relationship (a finds B, then B is the parent, and A is a child).
When 2 objects have a lookup relationship, SOQL can search through the parent's information (query up), or through the parent lookup (query down).
Use the relationship between account and contact in Salesforce to do an example (Conatact look up account)
list<account> accounts = [select Id,name, (select Id,name from Contact) from account];
At this point, we get a set of account and know all the contact information under each account,
In Apex Code we can use list<contacts> Contacts = Accounts[0]. Contact;
In this way, we can retrieve contacts information again.
Let's do an example of an upward query:list<contact> contacts = [select Id,name,account.name from contact];
In this way, we can get different contacts and he corresponds to his own customer name information.
For the time being, summarize up and down queries today.
About SOQL (i)