Here are 2 ways to do this. The first method uses your approach, however, it will be slow with large data tables
Names Default To Here( 1 );
// create sample data
dtMain = New Table( "Main",
Add Rows( 2 ),
New Column( "lot",
Character,
"Nominal",
Set Values( {"a", "b", "c", "d", "e", "a", "b", "c"} )
)
);
dtSmall = New Table( "Small",
Add Rows( 2 ),
New Column( "lot",
Character,
"Nominal",
Set Values( {"a", "e"} ),
Set Display Width( 49 )
)
);
Names Default To Here( 1 );
dtMain << clear select;
For( i = 1, i <= N Rows( dtSmall ), i++,
dtMain << select where(
dtMain:Lot == dtSmall:Lot[i],
current selection( "extend" )
)
);
The second one will work more efficiently
Names Default To Here( 1 );
// create sample data
dtMain = New Table( "Main",
Add Rows( 2 ),
New Column( "lot",
Character,
"Nominal",
Set Values( {"a", "b", "c", "d", "e", "a", "b", "c"} )
)
);
dtSmall = New Table( "Small",
Add Rows( 2 ),
New Column( "lot",
Character,
"Nominal",
Set Values( {"a", "e"} ),
Set Display Width( 49 )
)
);
// Create a new column as a Select indicator
dtSmall << New Column( "Select", set each value( 1 ) );
// Update the Main table with values from the Small table
dtMain << Update( With( dtSmall ), Match Columns( :lot = :lot ) );
// Select the matching columns
dtMain << select where( :select == 1 );
// get rid of select columns
dtMain << delete columns( "Select" );
dtSmall << delete columns( "Select" );
Jim