How to find unique records between two tables and append them using MapBasic

Products affected: MapBasic™
Here's one way this could be solved using a 2 step process in MapBasic:

1. Use a SQL statement to select the Unique records into a Selection (temporary) table.
The syntax for this statement is of the form:  NOT column name IN (SELECT column name FROM second table).
This will create a table of unique records in a single selection statement, here's a worked example:

2. Append the temporary table (created during #1) to the "master" table.
Execute a MapBasic "Insert" statement to add the unique records to the master record. This will need to be done using a "Run Command" because we won't know the names of the fields to be included, they can be built up within a string variable, in this way the code is dynamic and adapts to different table structures. Here's an example:

Dim strFieldList as string
Dim strSQL as string
strFieldList = "COL1, COL2, COL3"
strSQL = "Insert Into TableA (" + strFieldList + ") Select " + strFieldList + "From Query1"
Run Command strSQL
UPDATED:  September 20, 2017