The intersection of multi-condition Tao selection in a single table is 60 points in another section.
Source: Internet
Author: User
The intersection of multi-condition filtering in a single table is 60 points in another section. add another score. this is the data table BuyID & nbsp; & AttributeID & nbsp; value1 & nbsp; & nbsp the intersection of multi-condition filtering in a single nb table is 60 points in another section.
This is a data table
BuyID AttributeID Value
1 single room for rent
1 2 0
1 3 1
1 4 1000
2 1 full set for rent
2 2 address
2 3 1
2 4 1000
3 1 single room for rent
3 2 9
3 3 10
3 4 1500
Condition 1: 'bubucteid' = 1 AND 'value' = 'single room rental'
Condition 2: 'bubucteid' = 4 AND 'value'> = 1000 AND 'value' <= 2000
How can I find the intersection of conditions 1 and 2?
That is to say, there is only one search result, 'bucketid' = 1
Try 1: SELECT * FROM jm_user_buy_attribute WHERE ('bubuteid' = 1 AND 'value' = 'single room rental ') OR ('bubucteid' = 4 AND 'value'> = 1000 AND 'value' <= 2000) group by BuyID
The search result is only the result that meets the conditions 1 or 2, but the intersection cannot be filtered out.
Test 2: SELECT * FROM jm_user_buy_attribute WHERE ('bubuteid' = 1 AND 'value' = 'single room rental ') OR ('bubucteid' = 4 AND 'value'> = 1000 AND 'value' <= 2000) group by BuyID
The result of the second search is to remove the same BuyID.
Try 3: SELECT * FROM region as b1 left join region as b2 on b1.BuyID = b2.BuyID where b1.AttributeID = 1 AND b1.Value = 'single room rental 'OR b2.AttributeID = 4 AND b2.Value> = 1000 AND b2.Value <= 2000
The search result is incorrect.
Http://bbs.csdn.net/topics/390325234
This is what I published in the MYSQL section!
After the problem is solved, please receive points
------ Solution --------------------
Select * from jm_user_buy_attribute where AttributeID = 1 AND Value = 'single room rental'
Get
Array
(
[0] => Array
(
[BuyID] => 1
[AttributeID] => 1
[Value] => Single room rental
)
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service