Select values that meet different conditions on different rows?

前端 未结 6 1992
甜味超标
甜味超标 2020-11-22 07:37

This is a very basic query I can\'t figure out....

Let\'s say I have a two column table like this:

userid  |  roleid
--------|--------
   1    |    1         


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-11-22 08:18

    select userid from userrole where userid = 1
    intersect
    select userid from userrole where userid = 2
    intersect
    select userid from userrole where userid = 3
    

    Won't this solve the problem? How good a solution is this on typical Relational DBs? Will query optimizer auto optimize this?

提交回复
热议问题