我试过
SELECT count(*) as count FROM rt_item WHERE MATCH('') AND sale between 1 and 2;
并获得了很多行。 但是狮身人面像抱怨
ERROR 1064 (42000): sphinxql: syntax error, unexpected BETWEEN, expecting IN near 'between 1 and 2'
当我尝试
时SELECT count(*) as count FROM rt_item WHERE MATCH('') AND sale not between 1 and 2;
我搜索了Sphinx官方文件,其中说:
WHERE子句。该子句将映射到全文查询和过滤器。比较运算符(=,!=,<,>,< =,> =),IN,AND,NOT和BETWEEN都受支持并直接映射到过滤器。 OR尚未得到支持,但将来会有所支持。支持MATCH('查询')并映射到全文查询。
但它没有关于NOT BETWEEN的例子。 谁能告诉我sphinxql是否支持NOT BETWEEN?如果支持,那么正确的语法是什么?
答案 0 :(得分:1)
不,不是NOT BETWEEN
。有一个NOT IN()
运算符,在这种特定情况下可能有所帮助
SELECT count(*) as count FROM rt_item WHERE MATCH('') AND sale not in (1,2);
(长距离变得麻烦)
这有点令人费解,但可以做到
SELECT count(*) as count,sale>=1 AND sale<=2 AS f FROM rt_item WHERE f=0
创建一个虚拟属性来模仿'between',然后检查false。
也可能找到
SELECT count(*) as count,sale < 1 OR sale > 2 AS f FROM rt_item WHERE f=1
清晰。颠倒逻辑。
(空匹配()什么都不做,可以省略)