J'ai la requête suivante, qui effectue une recherche de texte intégral (CONTAINSTABLE) sur la table Produits et renvoie 1 enregistrement.SQL Server 2008 - limitation de la requête par FK
Chaque produit est référencé par les ShopProducts tableau (chaque ShopProduct représente un produit dans un magasin et est a une clé étrangère à Products.ProductId. Chaque ligne de la ShopProducts table a une ShopId colonne
Ma question est -. comment puis-je limiter la requête ci-dessous pour retourner uniquement Produits que ne pas ont un ShopProduct pour le ShopId donné dans la variable @ShopId?
DECLARE @ShopId uniqueidentifier
DECLARE @FullTextQuery nvarchar(1000)
SET @ShopId = 'a7e7d519-27f0-4d95-a1dd-87d992a0478c'
SET @FullTextQuery = 'ISABOUT("*Palmolive*","*Naturals*","*Shower*","*Milk*","*Nourishing*","*With*","*Honey*")'
SELECT TOP 1
ftt.RANK,
p.ProductId,
p.SearchableDescription
FROM Products p
JOIN CONTAINSTABLE(Products,
SearchableDescription,
@FullTextQuery) AS ftt ON ftt.key = p.ProductId
ORDER BY ftt.RANK DESC