diff --git a/_FiveSql2/src/TSqlExecutor.prg b/_FiveSql2/src/TSqlExecutor.prg index b5c486f..1d1483b 100644 --- a/_FiveSql2/src/TSqlExecutor.prg +++ b/_FiveSql2/src/TSqlExecutor.prg @@ -1297,7 +1297,11 @@ METHOD RunSelect() CLASS TSqlExecutor IF aCols[ i ][ 1 ][ 1 ] == ND_FN .AND. Len( aCols[ i ][ 1 ][ 3 ] ) > 0 xArgExpr := aCols[ i ][ 1 ][ 3 ][ 1 ] IF xArgExpr[ 1 ] == ND_COL .AND. xArgExpr[ 2 ] != "*" - cBare := SqlExprName( xArgExpr ) + /* Use the FULL qualified name (e.g. "o.amount") so + * FetchRow → FindWA resolves to the right workarea + * in JOIN contexts. Bare "amount" would fall through + * to aTables[1] which may be a different table. */ + cBare := xArgExpr[ 2 ] lFound := .F. FOR j := 1 TO Len( aResultExprs ) IF Upper( aResultExprs[ j ][ 2 ] ) == Upper( cBare )