我有下一列的表person_content:
我需要选择所有的人,谁是与N以上的content_ids或有is_star标志,使用SphinxQL。
我问题的第一部分可以用COUNT、GROUP BY和HAVING来解决。
SELECT person_id, COUNT(DISTINCT content_id) as t
FROM person_content
GROUP BY person_id HAVING t > N;是否可以将is_star条件添加到请求中?或者,例如,以某种方式向is_star * N添加t
发布于 2014-11-23 17:14:51
如果我正确理解,你想要那些t > N或is_star是真的。如果是这样的话,我认为这应该适用于你:
SELECT person_id, COUNT(DISTINCT content_id) as t, is_star
FROM person_content
GROUP BY person_id HAVING t > N or is_star;having子句中的任何内容都必须是select语句中的选定列。
https://stackoverflow.com/questions/27091761
复制相似问题