SQL: how to select a single id (“row”) that meets multiple criteria from a single column

后端 未结 9 2361
刺人心
刺人心 2020-11-30 05:38

I have a very narrow table: user_id, ancestry.

The user_id column is self explanatory.

The ancestry column contains the country from where the user\'s ancest

9条回答
  •  隐瞒了意图╮
    2020-11-30 06:11

    SELECT DISTINCT (user_id) 
    FROM [user]
    WHERE user.user_id In (select user_id from user where ancestry = 'England') 
        And user.user_id In (select user_id from user where ancestry = 'France') 
        And user.user_id In (select user_id from user where ancestry = 'Germany');`
    

提交回复
热议问题