SQL select rows with only a certain value in them

前端 未结 5 1434
半阙折子戏
半阙折子戏 2020-12-28 19:49

I have a table as such

Col 1 Col 2 Col 3
1       A     1
2       A     2
3       B     1
4       C     1
5       C     2
6       D     1

Ho

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 20:08

    It's a bit hard to know exactly what you're trying to get, but this is my best guess:

    SELECT * FROM theTable WHERE col2 NOT IN
      (SELECT col2 FROM theTable WHERE col3 <> 1)
    

提交回复
热议问题