How to get rows only contains multiple ID using SQL? Let say I have this table:

id | foo
1  | 100
1  | 200
1  | 200
2  | 300
2  | 300
3  | 200
4  | 100


I am expecting to have this result:

id | foo
1  | 100
1  | 200
1  | 200
2  | 300
2  | 300


I want to get only rows that have multiple id log, regardless of the foo value.
You can try this:

SQL&gt; select * from dummy;

    ID    FOO
---------- ----------
     1    100
     1    200
     1    200
     2    300
     2    300
     3    200
     4    200

7 rows selected.

SQL&gt; select * from dummy where id in (select id from dummy having count(*) &gt; 1 group by id);

    ID    FOO
---------- ----------
     1    100
     1    200
     1    200
     2    300
     2    300

SQL&gt;