2010-11-26 8 views
1

Qeと時間を割い:1)MySQLのクエリは

select 
    a.finishproductid 
from 
    tblt_invoiceorderitems a, tblm_invoiceorder b 
where 
    b.invoiceorderdate <= 'Current Date' and 
    a.invoiceorderid = b.invoiceorderid 

---それ以上の16kのレコードを持っています。

Qeと:2)

select jobcardid, stockcode 
from tblm_finishproduct 
where productionentrydate <= 'Current Date' 

---それはまた、より16Kレコードを有しています。

今私は2番目のクエリから最初のクエリではありません。

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 
); 

今、その時間

+0

SQLのコードブロックを使用してください。 – robert

答えて

0

これは、あなたの質問に対応していませんが、あなたはどこclause--でa.invoiceorderid = b.invoiceorderidを使用すべきではありません最初のクエリーの代わりにこのクエリーを試してみてください。 Natural joinは、表全体のクロス積を作成し、一致する行のみを選択するより効率的です。

select a.finishproductid 
from tblt_invoiceorderitems a 
natural join tblm_invoiceorder b 
where b.invoiceorderdate <= 'Current Date' 
0

を服用していないからこれを削除します。

b.invoiceorderdate <= 'CurrrntDate' and 
0

"select Table1、Table2、Table3"の結果は16k^3または16k^2です。検索のために主キーを使用して "内部結合"または "結合"を行う必要があります。

を参照してください。