Oracle query to match all values in the list among all rows in table

后端 未结 3 1951
醉话见心
醉话见心 2021-01-14 14:57

I have a table structure as under:

ID    A     B
--   ---  -----
 1    a     a1
 2    b     b1
 3    a     a2
 4    c     a1
 5    b     b2

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 15:31

    SELECT DISTINCT A      
    FROM tablename   
    WHERE B = 'a1'
    OR B = 'a2'     
    

    I think this should do the trick. Distinct is added so the value 'a' in A will only display once.

提交回复
热议问题