Consider I have a table named table1 which contains following data:
id, value
1, a
1, b
1, c
1, d
2, a
2, b
2, c
3, b
3, c
4, a
4, b
4, c
4, d
I wanted to select all ids that have a value = d. How could I achieve this?
Which means I need to get the result of ( 1 and 4 ) , since id 2 and 3 do not contain d.
the actual table contains more than 10,000,000 rows, so the query should not be too slow.
Thanks for your ideas.
You don’t need a join at all: