1

I have a table that looks like this:

Index  |  Condition
1      |     A
1      |     B
1      |     C
2      |     A
2      |     B
3      |     A

In mySQL, how would I select the index number that meets condition A and condition B. As in I want it to only select 1 and 2.

Thanks

Matt
  • 13,833
  • 2
  • 16
  • 28
erik12324
  • 101
  • 1
  • 1
  • 2

1 Answers1

0
select Index 
From yourable 
WHERE
    Condition IN ('A','B')
Group by
    Index 
Having count(DISTINCT Condition) = 2

Yep as prdp said group by and count. I prefer this pattern over conditional aggregation but both should get you the answer you want.

Matt
  • 13,833
  • 2
  • 16
  • 28