我被环顾四周,没有运气。
所以我对sphinx有一个复杂的查询,想知道我是否可以像这样对SQL进行复杂的查询
SELECT * FROM Table WHERE (categoryid in (17,18,19, 20) OR merchantid in (110,112,335)) AND brandid NOT in (20, 30, 40,50);
我知道OR正在使用SetSelect和
$s->SetSelect('*, IN(categoryid, 17,18 19) OR IN(merchantid,110,112, 335) AS test');
$s->SetFilter('test', array(1), true);
$s->query("", "index");
NOT查询可以作为单独的查询
完成$s->SetSelect('*, IN(brandid,20,30,40,50 AS nottest');
$s->SetFilter('nottest', array(1));
$s->query("", "index");
但是我应该如何在一个查询中合并
答案 0 :(得分:0)
对于'OR',您使用与setSelect
相同的技术像
这样的东西SELECT *, (categoryid in (17,18,19, 20) OR merchantid in (110,112,335)) AS test
FROM Table
WHERE test = 1 AND brandid NOT in (20, 30, 40,50);