ai didi

php - 如何计算与此查询中的字符串文本匹配的数据数量?

转载 作者:行者123 更新时间:2023-11-29 14:51:43 24 4
gpt4 key购买 nike

mysql_query("SELECT DISTINCT lo_category FROM questions where question_text = '" . mysql_real_escape_string($_GET["choice"]) . "'");

因此,从上面的查询中,我将获得与选择匹配的 lo_categories。我如何获得类别的数量,例如

Category Cognitive : 3 matches
Category Psychomotor : 1 matches
Category Perception : 0 matches

($_GET["choice"]) 来自具有多个选择的 html 复选框。这是我的问题表。

question_id  question_text               keyword  lo_category lo_domain
1 Define the word paraphrase Define Knowledge Cognitive
2 describe the meaning of NLP describe Knowledge Cognitive
3 describe the meaning of NLP describe Perception Psychomotor
4 describe the meaning of NLP describe Receiving Affective
5 Define this Define Knowledge Cognitive

更新了这个,有错误。请帮助我迷路!!!

$yes=mysql_query("select lo_category, count(*) from questions where question_text='" . mysql_real_escape_string($_GET["choice"]) . "' group by lo_category order by lo_category");

while ($row = mysql_fetch_assoc($yes)) {
echo '<b>Category :</b> ' . $row['lo_category'] . ',' . $row['count(*)'] . '<br />';
}

请帮助我,我是这方面的初学者..提前致谢!!!

最佳答案

select lo_category, count(lo_category) as countOflo_category group by lo_category

关于php - 如何计算与此查询中的字符串文本匹配的数据数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5591727/

24 4 0
文章推荐: mysql - Orbeon 3.9.0 远程/网络 Mysql 服务器
文章推荐: android - 在运行时在 TextView 中设置文本
文章推荐: android - 移动图书馆或图片库示例
文章推荐: Android裁剪图像大小
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com