MySql FULLTEXT 与查找表中的关键字列表匹配
我不知道这是否可行,但它会简化我的计算,以便能够通过单个查询来匹配查找表中的每个单词。 (否则,我可能会将表拉入内存并在 python 中编写一系列查询):
SELECT count(*) FROM input_form
WHERE MATCH (title,story) AGAINST (word);
上面将返回包含“word”的故事数量的计数,但是有什么方法可以让它重复这个计数对于包含这些单词的表中的每个单词?
SELECT
word,
count(MATCH (title,story) AGAINST (word))
FROM keywords;
类似的事情?请注意,标题和故事来自一张表,单词来自另一张表。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有点生疏,但我认为你想使用嵌套选择:
如果我记得的话,你可能需要添加另一层嵌套。
I'm a little rusty, but I think you want to use nested selects:
You may have to add another level of nesting if I recall.
是的。一段时间后,我认为这在 MySql 中几乎是不可能的,但我确实在循环内使用了 python MySql 模块的 db.cursor() 和cursor.execute() 方法来生成所需的表,然后将其上传到数据库(因为为页面动态执行此操作会很疯狂)。
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).