如何在使用B-Tree索引时查找MySQL语句的总行数?

时间:2014-06-16 10:29:28

标签: mysql sql

我有以下查询,当我添加计数(*)时返回零结果集,我需要找到影响搜索关键字的总行数,我该如何在MYSQL中执行此操作?

SELECT `url` , `search_id` , `total` , `keyword`, `title`, `description`, 

( ( 1.5 * (MATCH(`title`) AGAINST ('keyword1 keyword' IN BOOLEAN MODE)) * 1000 ) + ( 1.0 * (MATCH(`description`) AGAINST (''keyword1 keyword' IN BOOLEAN MODE)) * 1000 ) ) AS relevance , count(search_id) AS found 

FROM search_si 

WHERE 

MATCH (`keyword`,`title`,`description`,`url`) AGAINST (''keyword1','keyword'' IN NATURAL LANGUAGE MODE ) 

-- GROUP BY `url` 
ORDER BY relevance DESC 

LIMIT 140,10  

如果我添加一个像下面这样的计数它给我零,空集我不知道为什么,

SELECT count(*)AS `found`, `url` , `search_id` , `total` , `keyword`, `title`, `description`, 

( ( 1.5 * (MATCH(`title`) AGAINST ('keyword1 keyword' IN BOOLEAN MODE)) * 1000 ) + ( 1.0 * (MATCH(`description`) AGAINST (''keyword1 keyword' IN BOOLEAN MODE)) * 1000 ) ) AS relevance , count(search_id) AS found 

FROM search_si 

WHERE 

MATCH (`keyword`,`title`,`description`,`url`) AGAINST (''keyword1','keyword'' IN NATURAL LANGUAGE MODE ) 

-- GROUP BY `url` 
ORDER BY relevance DESC 

LIMIT 140,10  

0 个答案:

没有答案