求助,查询 (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 TABLENAME
(Attr = 'Length' AND Value = 6.00000)
OR (Attr = 'DIAM' OR Value = 0.250000)
OR (Attr = 'TIP' AND Value = 'FLAT')