Qe : 1)
select
a.finishproductid
from
tblt_invoiceorderitems a, tblm_invoiceorder b
where
b.invoiceorderdate <= 'Current Date' and
a.invoiceorderid = b.invoiceorderid
--- it has more than 16k records.
Qe : 2 )
select jobcardid, stockcode
from tblm_finishproduct
where productionentrydate <= 'Current Date'
--- it has also more than 16k Record.
Now i Want From 2nd Query not in first query.
select jobcardid, stockcode
from
tblm_finishproduct
where
productionentrydate <= 'CurrrntDate' and
finishproductid not in
(
select
a.finishproductid
from
tblt_invoiceorderitems a, tblm_invoiceorder b
where
b.invoiceorderdate <= 'CurrrntDate' and
a.invoiceorderid = b.invoiceorderid
);
Now its ta开发者_如何转开发king a time
This does not address your question, but you should not be using a.invoiceorderid = b.invoiceorderid
in your where clause--try this query in place of the first one. Natural join is more efficient than making a cross product of the entire table and selecting only those rows that match.
select a.finishproductid
from tblt_invoiceorderitems a
natural join tblm_invoiceorder b
where b.invoiceorderdate <= 'Current Date'
Remove this from the not in:
b.invoiceorderdate <= 'CurrrntDate' and
the result of "select Table1, Table2, Table3" maby is 16k^3 or 16k^2. You need make a "inner join" or "join" using primary key to cout the search.
See u.
精彩评论