|100 | | 100 | | 100|If Not I think you have an Index on it & must Use it for optimization w/o any LEFTs & TRIMs.
c_field = "100"+SPACE(LenOfTheIDField-3) SELECT * FROM table1; where table1.id in (select table2.id from table2 where testfield=c_field); union all; SELECT * FROM table2; where testfield=c_field and; table2.id in (select table1.id from table1) order by 91,93 into cursor tempJust a thought.