0

MOF と SIL の両方の場所に存在するタイトル (t.processed) のリストを返し、そのリストから SIL に存在するタイトルを差し引こうとしています

改訂:

select t.processed, i.call
from item i, title t
where i.bib# = t.bib#
    and i.collection = 'PIC'
    and i.location in ('MOF', 'SIL')
except
select t.processed, i.call
from item i, title t
where i.bib# = t.bib#
    and i.collection = 'PIC'
    and i.location = 'SIL'

残念ながら、これは結果を返しませんが、必要なものに少し近づいています

サンプル出力はかなり単純です (そして柔軟です):

processed        call
Mouse count      P WAL
Fly away home    P BUN

さらに明確にするために: SIL と MOF の両方の場所で繰り返されるタイトル (例: Fly away home) を見つけて、そのリストから SIL の場所で発生するタイトルを削除したいと思います。

4

4 に答える 4

1

アイテムが次のようなものであると仮定します

ID Item Collection Location
1  1    PIC        MOF
2  1    PIC        SIL
3  2    PIC        MOF
4  3    PIC        SIL

それから

Select select mof.item#, mof.call, mof.collection From Item mof
Left Join Item sil On mof.Item# = sil.Item# and sil.Collection = mof.Collection
Where sil.Location = 'SIL'
and mof.Location = 'MOF'
and mof.Collection = 'PIC'
and sil.ID is null

あなたを近づけます。古い結合構文で停止します...

于 2013-06-05T16:11:16.933 に答える
0

EXCEPT演算子は、少なくともいくつかの種類の SQL ではこれを行います。

select i.item#, t.processed, i.call, i.collection
from item i, title t
where i.bib# = t.bib#
    and i.collection = 'PIC'
    and i.location = 'MOF'
except
select i.item#, t.processed, i.call, i.collection
from item i, title t
where i.bib# = t.bib#
    and i.collection = 'PIC'
    and i.location = 'SIL'
于 2013-06-05T15:52:30.717 に答える