Question: I am comparing 2 tables which are mostly the same but there have been some amendments, in effect comparing a new version to the old one and displaying all the records with changes in a selection table based on a unique ID.

I run into problems with the following SQL part of the script:

```sql
Select * From selectedTableNew, selectedTableOld 
Where (selectedColumnNew = selectedColumnOld) 
And (aColNew <> aColOld) 
Into AmendedRecords

```

I receive the error 

> 
> No join specified between *selectedTableNew* & *selectedTableOld*. Invalid join condition in WHERE clause."
> 
> 
>

Answer: 
Make sure that you are using Alias variables in your SQL statement. You might want to change it to something along these lines:

```sql
Dim columnNew, selectedColumnNew, selectedTableNew As String
Dim columnOld, selectedColumnOld, selectedTableOld As String
Dim aSelectedColumnNew, aSelectedColumnOld, aColNew, aColOld As Alias

-- Here you assign the values to the string variables
-- I'm assuming you are using a dialog to ask the ser for input
selectedTableNew = "SomeTable"
selectedColumnNew = "SomeColumn"
columnNew = "SomeOtherColumn"
selectedTableOld = "SomeTable2"
selectedColumnOld = "SomeColumn2"
columnOld = "SomeOtherColumn2"

-- Now you link the table and columns to create a Alias
aSelectedColumnNew = selectedTableNew & "." & selectedColumnNew
aSelectedColumnOld = selectedTableOld & "." & selectedColumnOld
aColNew = selectedTableNew & "." & ColumnNew
aColOld = selectedTableOld & "." & ColumnOld

Select * From selectedTableNew, selectedTableOld 
   Where (aSelectedColumnNew = aSelectedColumnOld) 
   And (aColNew <> aColOld) 
   Into AmendedRecords

```

This should give you the records where the "selected" columns are identical and where the "other" column aren't.

Make sure that SelectedColumnNew/-Old are the ID's that should be the same in the two tables
This could be solved with MapBasic like

> 
> SELECT \* FROM **TABLE\_1** WHERE NOT *table\_1\_column* IN (
>  SELECT *table\_2\_column* FROM **TABLE\_2**
>  ) INTO Selection
> 
> 
> 

or as a code

```sql
SELECT * FROM TABLE_1 WHERE NOT table_1_column IN (
    SELECT table_2_column FROM TABLE_2
) INTO Selection

BROWSE * FROM Selection

```

or with SQL select

[![enter image description here](https://i.stack.imgur.com/OZ9XV.png)](https://i.stack.imgur.com/OZ9XV.png)