我有一个不起作用的php / mysql脚本!我需要找出一个字符串确实存在多少行,我必须从一个"布尔全文"功能
这是不起作用的代码:
$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)");
我该怎么办?
答案 0 :(得分:0)
这样做你想要的吗?
SELECT COUNT(homeid)
FROM notes
WHERE MATCH(title, text, tags) AGAINST('+$searchstring*' IN BOOLEAN MODE) > 0;
如果可以重复homeid
,您可能真的需要count(distinct homeid)
。
答案 1 :(得分:-1)
这应该是一个subselect吗?如果没有,你有两个来自
"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)