我正在尝试使用HAVING过滤查询但是我得到了这个错误:
mysql> SELECT id FROM related_tags GROUP BY application_id HAVING COUNT(*)=10;
ERROR 1064 (42000): sphinxql: syntax error, unexpected IDENT, expecting $end near 'HAVING COUNT(*)=10'
我正在使用Sphinx 2.2.6-id64-release,它支持HAVING
这是我的索引,如果它确实重要(application_id属性用于按ID分组)。
sql_query = \
SELECT `id`, `id` as `application_id`, `clear_title`\
FROM `applications`\
WHERE `id`>=$start AND `id`<=$end
sql_query_range = SELECT MIN(id),MAX(id) FROM applications
sql_attr_uint = application_id
sql_attr_multi = uint tag_id from query; \
select application_id, tag_id \
from application_tag_stemmed2;
答案 0 :(得分:0)
我认为你必须使它成为一个虚拟属性,HAVING子句本身不允许使用任意表达式。
SELECT id,COUNT(*) AS cnt FROM related_tags GROUP BY application_id HAVING cnt=10;