fixed indexed join to use foreign keys from table1