>The first process that I attempted is not going to work because of the number of crazy sequences to process. So I was wondering if there was a optimized method to search additional two tables from a table with a sequence of invoice numbers.
>
>I have a tableA with various amounts of invoices. I need to search a current table (tableB) and an archive table (tableC) for any of the invoices listed in tableA. Essentially, the system will search for the invoice in tableB first, but if it is not found it will search tableC. Either way, when the invoice is found from either tableB or tableC, the information will be place into a cursor.
>
>I attempted a SQL, but it froze halfway through...here is my code:
>
>
>select * from invoice_temp ;
>left outer join current_items.inv_no on inv_no ;
>left outer join archive_items_old.inv_no on inv_no ;
>into cursor sql_test
>
Try
SELECT * FROM current_items ;
WHERE inv_no IN ( ;
SELECT inv_no FROM invoice_temp) ;
UNION ;
SELECT * FROM archive_items ;
WHERE inv_no IN ( ;
SELECT inv_no FROM invoice_temp) ;
INTO CURSOR whatever
SELECT * FROM invoice_temp ;
WHERE inv_no IN ( ;
SELECT inv_no FROM current_items) ;
OR inv_no IN ( ;
SELECT inv_no FROM archive_items) ;
whichever suits you.
--sb--