Home > Backend Development > PHP Tutorial > 求一条mysql查询语句~~~~~~~!!!!!!!!

求一条mysql查询语句~~~~~~~!!!!!!!!

WBOY
Release: 2016-06-23 14:12:41
Original
962 people have browsed it

MySQL PHP

希望将满足两个条件之一的所有行都通过一条语句查询出来,这样方便排序,例如:
条件1:flag = 1 , type = 1,
条件2:flag = 2 , type = 2,

满足上面一个条件即可,通过一条select语句得到结果,这个可行么?我希望是可行的,那样就免去了再php里面排序了。

回复讨论(解决方案)

select * from tbl_name where (flag=1 and type=1) or (flag=2 and type=2)

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