0

NOT IN の代わりに以下のクエリで NOT EXIST を使用したい。

Select * From Currencymaster Where Currencycode Not In ('USD');

私は次のように書いてみました:

Select currencycode from currencymaster where not exists (select currencycode from currencymaster where currencycode='USD');

これが正しいかどうかはわかりません。それは私に何の結果ももたらさないからです。

確認するか、書き直すように案内してください。ありがとう

4

1 に答える 1

3
Select currencycode  
  from currencymaster a
 where not exists (select currencycode 
                     from currencymaster b 
                    where b.currencycode='USD' 
                      and a.currencycode=b.currencycode);

select currencycode from currencymaster where currencycode='USD'常に行が見つかったので、常に条件に行を返します。それをcurrencycode='USD機能させるには、別の行を追加して、メインテーブルの行、つまりAが通貨= 'USD'を持っているチェックを条件付けする必要があります。

通貨だけをチェックする場合は、このように試すことができます..

 Select currencycode  
      from currencymaster WHERE currencycode!='USD'
于 2013-07-19T06:04:24.033 に答える