Sunday, 15 May 2011

php - How to make conditions with CASE WHEN in SphinxQL? -


How can I set the condition for a spinks search? In my custom MySQL code, as follows:

How can I re-code it as a Spinks search?

  $ condition = "(in case related_type = 'course' THEN related_ id = 1 ELSE related_id IN (2, 3,4) END)"; << Code>   

There is a IF () function in SPINXQUL Used in the same fashion

For example:

  SELECT *, IF (related_type = 'course', related_id = 1, IN (related_id, 2,3) , 4)) as filter from myindex where the filter = 1  

should be in the SELECT section, not in WHERE

(Note also a slightly different syntax for IN .) This function is in Sphinx


No comments:

Post a Comment