Find a mysql Query statement ~~~~~~~!!!!!!!! You want to query all rows that meet one of the two conditions in one statement to facilitate sorting. for example, condition 1: flag & nbsp ;=& nbsp; 1 & nbsp ;, & nbsp; type & nbsp ;=& nbsp; 1, condition 2: flag & nbsp ;=& nbsp; 2 & nbsp ;, & find a mysql Query statement ~~~~~~~!!!!!!!!
You want to query all rows that meet one of the two conditions in one statement to facilitate sorting. for example:
Condition 1: flag = 1, type = 1,
Condition 2: flag = 2, type = 2,
Is it feasible to obtain the result through a select statement if the preceding condition is met? I hope it is feasible, so it eliminates the need for sorting in php. Share MySQL PHP:
------ Solution --------------------
Select * from tbl_name where (flag = 1 and type = 1) or (flag = 2 and type = 2)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.