Home > Database > Mysql Tutorial > 一个字段同时满足多个条件的查询_MySQL

一个字段同时满足多个条件的查询_MySQL

WBOY
Release: 2016-06-01 13:21:16
Original
1444 people have browsed it

bitsCN.com 所以需要一些特殊处理。

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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template