Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to search for all keywords inclusive
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01357215
Message ID:
01357224
Vues:
18
>I didn't said you can do this with the same query in VFP :-)
>Try this in SQL Server:
>
>DECLARE @MyTable TABLE (Id int, Searched varchar(200))
>DECLARE @Keys    TABLE (Word varchar(200), Id int)
>
>INSERT INTO @MyTable VALUES (1,'Mother Father Daughter Son')
>INSERT INTO @MyTable VALUES (2,'Mother Daughter Son')
>INSERT INTO @MyTable VALUES (3,'Mother Son')
>INSERT INTO @MyTable VALUES (4,'Daughter Son')
>INSERT INTO @MyTable VALUES (5,'Mother Father Son')
>INSERT INTO @MyTable VALUES (6,'Son Daughter Father')
>INSERT INTO @MyTable VALUES (7,'Mother Son')
>INSERT INTO @MyTable VALUES (8,'Other Word')
>
>
>INSERT INTO @Keys VALUES ('Mother',1)
>INSERT INTO @Keys VALUES ('Father',2)
>INSERT INTO @Keys VALUES ('Son',3)
>INSERT INTO @Keys VALUES ('Daughter',4)
>
>DECLARE @nAllWords int
>SELECT @nAllWords = COUNT(*) FROM @Keys
>
>SELECT MyTable.*
>FROM @MyTable MyTable
>INNER JOIN (SELECT MyTable.Id
>                   FROM @MyTable MyTable
>            INNER JOIN @Keys KeyWords ON MyTable.Searched LIKE '%'+KeyWords.Word +'%'
>            GROUP BY MyTable.Id
>            HAVING COUNT(*) = @nAllWords) Tbl1 ON MyTable.Id = Tbl1.Id
>
>
>BTW in your example you wrote "FaRther: in KeyWords cursor :-)

I tried it and it worked great. Now I would like to understand how to make it work in VFP as well.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform