Part 2: Searching the Table
Now you have an easy to-use table of keywords and their associations. How do
you query this table? Here’s
what I do:
you query this table? Here’s
what I do:
First I format each searchterms passed into the script as
‘word1′,’word2′,’word3’ and stick it in a string
called
‘word1′,’word2′,’word3’ and stick it in a string
called
$querywords
.
Then I throw them into this SQL query:
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";