Hi all!
I'm having one (MySQL) table with two fields:
ref char(20),
type int
and some sample values:
+---------------------+-------+
| ref | type |
+---------------------+-------+
0| 2105 | 5 |
1| 2104 | 20 |
2| 2101 | 20 |
3| 2104 | 5 |
4| 2103 | 5 |
What I want is to select only those rows which for a given ref has no other rows with a type=20. In the example above this would result in that (obviously) row 1 and 2 would be excluded but also row 3 since another row with the same ref (2104) has a type=20.
Only rows 0, 2 and 4 should be selected.
I guessed this could be done by a self-join of some sort but didn't quite succeed...
Any ideas, anybody?