I don't know if this is possible, but it would simplify my calculations to be able to match against each word in a lookup table with a single query. (otherwise, I'll probably pull the tables into memory and program a sequence of queries in python):
SELECT count(*) FROM input_form
WHERE MATCH (title,story) AGAINST (word);
The above will return a count for number of stories that contain 'word', but then is there some way to have it repeat this count for every word in a table containing these words?
SELECT 开发者_运维百科
word,
count(MATCH (title,story) AGAINST (word))
FROM keywords;
Something like that? Note that title and story are from one table, and word comes from another.
I'm a little rusty, but I think you want to use nested selects:
SELECT tbl.word, count(*) FROM (SELECT * FROM input_form WHERE MATCH(title, story) AGAINST (word)) as tbl;
You may have to add another level of nesting if I recall.
Yup. After a while I decided this may be near impossible in MySql, but I did use the db.cursor() and cursor.execute() method of the python MySql module inside of a loop to generate the required table, then uploaded it into the database (since doing this dynamically for a page would be crazy).
精彩评论