all groups > sql server programming > august 2006 >
You're in the

sql server programming

group:

How to query a keywords table for multiple matches


RE: How to query a keywords table for multiple matches Steve Mann
8/8/2006 2:11:03 PM
sql server programming:
Can't you use IN ? I know its not the best for performance but it would be
like:

Keywords.Keyword IN ('one', 'two')

-=Steve

[quoted text, click to view]
RE: How to query a keywords table for multiple matches ML
8/8/2006 3:06:03 PM
Google for "relational division". Joe Celko wrote a nice article on the
subject.


ML

---
How to query a keywords table for multiple matches Derek Kurth
8/8/2006 8:42:14 PM
Hi, all,

I have a database of documents and keywords with two tables:
Documents(ID, some other fields)
Keywords(ID, Keyword)

So each document has a unique ID, and each row in the Keywords table holds
one keyword associated with a document.

I want to search for a match on multiple keywords, like this:

SELECT *
FROM Documents
LEFT JOIN Keywords on Documents.ID = Keywords.ID
WHERE Keywords.Keyword = 'one' AND Keywords.Keyword = 'two'

But that doesn't work (since a keyword can't be "one" and "two" at the same
time!). For an arbitrary number of keywords, I'm not sure the right way
to do this. I'd appreciate any help you can offer!

Thanks,
Dere

AddThis Social Bookmark Button