所以需要一些特殊处理。 复制代码 代码如下: SELECT * FROM news_extinfo where (ExtID = 1 and OptionValue = 0) or (ExtID = 2 and OptionValue = 0 ) or (ExtID = 3 and OptionValue = 0 ) group by NewsID having count(*)=3 此处 c
复制代码 代码如下:
SELECT * FROM news_extinfo
where
(ExtID = 1 and OptionValue = 0)
or (ExtID = 2 and OptionValue = 0 )
or (ExtID = 3 and OptionValue = 0 )
group by NewsID
having count(*)=3
此处 count(*) = 3 表示的意思是
在查询的结果中,只查出按group 分组之后,每个组的有3条数据的结果集