为什么这个 "count" 函数不起作用? (PHP/MYSQL)

Why does this "count" function not work? (PHP/MYSQL)

我有一个无法运行的 php/mysql 脚本!我需要找出字符串中确实存在多少行,我必须从 "boolean full text" 函数中计算。

这是不起作用的代码:

$resuslt=mysql_query("SELECT COUNT(homeid) 
                       FROM notes 
                       WHERE MATCH(title, text, tags) AGAINST('+$searchstring*' IN BOOLEAN MODE) AS accurate 
                       FROM notes 
                       WHERE MATCH(title, text, tags) AGAINST ('+$searchstring*' IN BOOLEAN MODE)");

我该怎么办?

这是你想要的吗?

SELECT COUNT(homeid) 
FROM notes 
WHERE MATCH(title, text, tags) AGAINST('+$searchstring*' IN BOOLEAN MODE) > 0;

如果 homeid 可以重复,您可能真的想要 count(distinct homeid)

这应该是子选择吗?如果不是,你有两个发件人:

"SELECT COUNT(homeid) 
                       FROM notes 
                       WHERE MATCH(title, text, tags) AGAINST('+$searchstring*' IN BOOLEAN MODE) AS accurate 
                       FROM notes 
                       WHERE MATCH(title, text, tags) AGAINST ('+$searchstring*' IN BOOLEAN MODE)");

你可以试试这个:

SELECT (SELECT COUNT(homeid) 
                           FROM notes 
                           WHERE MATCH(title, text, tags) AGAINST('+$searchstring*' IN BOOLEAN MODE)) AS accurate
                           FROM notes 
                           WHERE MATCH(title, text, tags) AGAINST ('+$searchstring*' IN BOOLEAN MODE)