1
我有一個連接表與兩列組合主鍵。 我想查詢所有條目具有計數和列查詢的組合
columnA having count > 1
和
columnB = value1 and value2
我的查詢到目前爲止是這樣的
select
columnA
from tableA
where columnB = 1 and
columnA in (
select
columnA
from tableA
group by columnA
having count(columnA) > 1)
或
select
columnA
from tableA
where columnB = 2 and
columnA in (
select
columnA
from tableA
group by columnA
having count(columnA) > 1)
我如何可以查詢
...columnB = 1 and columnB = 2 and columnA in (select ....
感謝的作品,但如果我想查詢計數(columnA)= 2? – Markus 2014-12-04 10:12:55
然後將'count(columnA)= 2'加到最後。 – 2014-12-04 10:15:01
但不給我這也columnB組合(1,3),因爲(1,2)中的列B是一個或鏈接是不是? – Markus 2014-12-04 10:17:31