Select * From KTrackTagDetail ; >> where (Seqno In (Select Seqno From C_Kits) ; >> or SeqnoFG In (Select Seqno From C_Kits)) ; >> and Left (RecordType,2) # 'AP' ; >> into Cursor C_Detail>>So, how can I speed this up?
>select ... >from myTable T where exists (select 1 from c_Kits K where K.SeqNo = T.SeqNo) and NOT RecordType LIKE 'AP%' >UNION >select ...from myTable T where exists (select 1 from c_Kits K where K.SeqNo = T.SeqNoFG) and NOT RecordType LIKE 'AP%'One more thing - assuming you have an index on both SeqNo and SeqNoFG and LEFT(RecordType,2) then add NOFILTER to your select statement.