您好,欢迎访问一九零五行业门户网

单表多条件淘选交集60分在另外的板块,完成进去另外领分

单表多条件筛选交集60分在另外的板块,完成进去另外领分
这是数据表
buyid   attributeid   value
1            1       单间出租
1            2          0
1            3          1
1            4        1000
2            1       整套出租
2            2        地址
2            3          1
2            4        1000
3            1       单间出租
3            2          9
3            3         10
3            4        1500
条件一:`attributeid`=1 and `value`='单间出租'
条件二:`attributeid`=4 and `value`>=1000 and `value`
我改如何搜索出条件一和条件二的交集呢?
即搜索出的结果只有一条,`buyid`=1
尝试一:select * from jm_user_buy_attribute where (`attributeid`=1 and `value`='单间出租') or (`attributeid`=4 and `value`>=1000 and `value`尝试一搜索出来的结果只是满足条件一或者条件二的结果,但不能筛选出交集。
尝试二:select * from jm_user_buy_attribute where (`attributeid`=1 and `value`='单间出租') or (`attributeid`=4 and `value`>=1000 and `value`尝试二搜索出来的结果只是去除了相同的buyid
尝试三:select * from jm_user_buy_attribute as b1 left join jm_user_buy_attribute as b2 on b1.buyid=b2.buyid where b1.attributeid=1 and b1.value='单间出租' or b2.attributeid=4 and b2.value>=1000 and b2.value尝试二搜索出来的结果不正确。
http://bbs.csdn.net/topics/390325234
这是我在mysql板块那里发布过的!
解决问题后可以请进去领分
------解决方案--------------------
单独 select * from jm_user_buy_attribute where attributeid=1 and value='单间出租'

array
(
    [0] => array
        (
            [buyid] => 1
            [attributeid] => 1
            [value] => 单间出租
        )
[1] => array
        (
            [buyid] => 3
            [attributeid] => 1
            [value] => 单间出租
其它类似信息

推荐信息