# SubTables

A comma-separated list of sections in the configuration file that configure extraction of data from sub tables (which contain data linked to the main table). For example:

    [MyTask]
    ConnectionString=...
    PrimaryKeys=item_id
    Template=inventory.tmpl
    SQL=SELECT * FROM inventory
    SubTables=SubTableSection

    [SubTableSection]
    Template=flow.tmpl
    SQL=SELECT * FROM flow WHERE item_id = @item_id

In the preceding example, the table `flow` is linked to the main table (`inventory`). The table `flow` has a separate SQL statement that is run for every row returned from the main table. The table also has its own template file, which is merged with the main template. For more information about constructing templates, see Construct Template Files.

The tables are linked by the `item_id` column. In the SQL statement for the `flow` table, the connector replaces `@item_id` with the `item_id` returned from the `inventory` table. (The connector replaces any items in the SQL statement marked with `@` with the value from the main table).

If the main query returned rows with the `item_id` column ranging from 1-10, the connector would run another query for each row. The first would be:

    SELECT * FROM flow WHERE item_id = 1

and the second would be:

    SELECT * FROM flow WHERE item_id = 2

and so on.

Type: | String
Default: |
Required: | No
Configuration Section: | TaskName or FetchTasks
Example: | `Subtables=Table1,Table2`
See Also: | SQL Template

_FT_HTML5_bannerTitle.htm