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.
Best Answer
Variant 1 (The Censored DBA's solution with syntax correction):
Variant 2 (subquery in FROM clause):
The index by
id
is safe for to increase performance in both variants.Variant 3. To improve performance you can try to use temporary table: