Select rows with different id but same values
First you have to filter the userid that appears more than one time:

select
userid
from table
group by userid
having count(1) &gt; 1


This will return:

userid
------
     5
     8


Now using this as a subquery you can select the complete result you want:

select 
*
from table
where userid in (
  select
  userid
  from table
  group by userid
  having count(1) &gt; 1
)