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')--算是基础SQL,不需要GROUP BY也行的,GROUP BY是比较消耗CPU的操作,能不用就别用
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')
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
FROM TABLENAME
(Attr = 'Length' AND Value = 6.00000)
OR (Attr = 'DIAM' OR Value = 0.250000)
OR (Attr = 'TIP' AND Value = 'FLAT')--算是基础SQL,不需要GROUP BY也行的,GROUP BY是比较消耗CPU的操作,能不用就别用
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')