问题
I need to create a sphinx query in my project with OR condition. But giving an OR condition like
select cost FROM transactionsChart WHERE cost=25 OR cost=5;
is not working. It returns an error like
ERROR 1064 (42000): sphinxql: syntax error, unexpected OR, expecting $end near 'OR cost=5'
Can anybody help me....
Thanks in advance
回答1:
Sphinx doesnt support OR
in the WHERE clause, only AND
.
For your specific example, could use IN
syntax,
sphinxql> SELECT cost FROM transactionsChart WHERE cost IN (5,25);
or a more general solution is to use a virtual attribute
sphinxql> SELECT cost, IF(cost=25 OR cost=5,1,0) AS filter
FROM transactionsChart WHERE filter = 1;
回答2:
Try with
select cost FROM transactionsChart WHERE cost=25 | cost=5;
Source - Official Documentation
来源:https://stackoverflow.com/questions/31199579/how-to-write-sphinx-queries-with-or-condition