gpt4 book ai didi

php - 在mysql中的指定列中获取具有相同随机单词的记录

转载 作者:行者123 更新时间:2023-11-29 21:44:23 26 4
gpt4 key购买 nike

我的表中有以下数据,

id               Description              Category
1 I am Desc with printer main category
2 I am desc with test test category
3 new printer desc third category
4 new test category printer category

等等......

我想找到描述字段中具有相同单词的计数(可以是类似打印机但未预定义的任何单词)。例如输出应该是:

Total      Word which is same
2 printer
2 test

我尝试使用 http://dev.mysql.com/doc/refman/5.7/en/fulltext-boolean.html带有 bool 选项的示例,但它没有给出所需的输出。

这是我给出的示例,打印机可以是任何东西。我不想在任何地方的查询中指定这个词,因为它可以是任何东西。只有在任何地方具有相同单词的描述才应该出现在输出中。

提前致谢。

最佳答案

试试这个:

SELECT SUM(IF(Description like '%printer%',1,0)) AS Printer,SUM(IF(Description like '%test%',1,0)) AS Test FROM `yourTable`

这可能有帮助:)

关于php - 在mysql中的指定列中获取具有相同随机单词的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34221285/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com