【吐血请教】sql查询语句
求助,查询 (Attr = Length 并且 Value = 6.00000) 并且 (Attr = DIAM 并且 Value = 0.250000) 并且 (Attr = TIP 并且 Value = FLAT) 的 ID_ITEM,我感觉这玩意爆难,要吐血了.求教大神解答,谢过先。不清楚的话尽管问哈。 sql 高级查询
[解决办法]
select id_item from (select distinct * from 表)a
where (Attr = Length and Value = 6.00000) or (Attr = DIAM and Value = 0.250000) or (Attr = TIP and Value = FLAT)
group by id_item
having count(1)>=3
[解决办法]
既然都distinct了,就=3就行了。>3也不可能出现。
[解决办法]
select distinct ID_ITEM
from [表名]
where (Attr='Length' and Value='6.00000')
or (Attr='DIAM' and Value='0.250000')
or (Attr='TIP' and Value='FLAT')