ショップタイプがあります。一部のショップタイプは他のショップタイプと互換性がありません(たとえば、食品の近くで自動車部品を販売することはできません)。
これが私のテーブルスキーマです:
create table TShopCompatibility
(
idshoptype1 int NOT NULL,
idshoptype2 int NOT NULL,
constraint pkSHOPCOMP primary key(idshoptype1,idshoptype2),
constraint fkSHOPCOMP1 foreign key(idshoptype1) references TShopType(idshoptype),
constraint fkSHOPCOMP2 foreign key(idshoptype2) references TShopType(idshoptype),
constraint cSHOPCOMP12 check(idshoptype1>idshoptype2)
)
私はこれらの値を持っています:
2 - 1
3 - 1
5 - 1
5 - 2
10 - 9
12 - 11
13 - 10
どのようにid-shoptypes。たとえばidshoptype=2と互換性のあるショップを取得するにはどうすればよいですか?