Nested For each commands are used to retrieve nested records, typically involving related data across multiple tables.
GeneXus can automatically infer the desired behavior based on the structure of these commands.

What actions would GeneXus detect that we want to execute with this type of structures, so that it can infer the behavior automatically?
- For each record of a table, to retrieve some records from another table: the related ones. (Learn more about this case of use known as Join)
- For each record of a table, to retrieve all the records from another table. (Learn more about this case of use known as Cartesian Product)
- To process information by groups; that is to say, to group the records from a table according to the value of an attribute or group of attributes and, for each group, to retrieve some records: the ones corresponding to the group. (Learn more about this case of use known as Control Break)
The relation is always one to many: for each record from a table, to recover many records from another table (it may be the same table).