Search Engine

admin

Administrator
Staff member
I am referring to "Slapping together a search engine for your database is easy with PHP and MySQL" by Clay Johnson located at:

<!-- m --><a class="postlink" href="http://phpbuilder.com/columns/clay19990421.php3?page=2">http://phpbuilder.com/columns/clay19990421.php3?page=2</a><!-- m -->


The author used something like this:

SELECT count(search_table.word) as score, search_table.qid,your_table.blob
FROM search_table,your_table
WHERE your_table.qid = search_table.qid AND search_table.word
IN($querywords)
GROUP BY search_table.qid
ORDER BY score DESC";


This will select all qid that contain ANY ONE word give by the $querywords, meaning that if I give it 3 words, it will first show the ones that match all 3, then match 2, then match 1, and so on.

But if I would like to select ONLY those who match ALL 3, how can this be done? I tried to add one more line:

AND score = $num_of_words

but it doesn't seem to work. Can anyone give me some suggestions?

Thank you very much!
 
Back
Top