当一个字段需要同时等于多个值的时候,用and直接连不会有数据查出。

所以需要一些特殊处理。

 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条数据的结果集 

 

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2021-11-27
  • 2021-11-24
  • 2021-12-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-06-18
  • 2021-07-27
  • 2021-11-27
相关资源
相似解决方案