There is a table with 2 columns:
x y
1 1
1 2
1 3
2 2
2 3
2 4
3 1
3 2
3 5
If I need to find all X, where Y = 5. I use query
SELECT * FROM table WHERE y = 5
But, I need to find all X, where Y = 2 AND Y = 3.
How to do this on 1 query?
In result I must to get X = 1 and 2 (NOT 3!). And Y may be many
If i use SELECT * FROM table WHERE y IN (1, 2)
I will get x = 1, 2, 3, but I not need Y = 3 because in table no line x=3, y=3
if unique contraint was not specified for each x, then
DISTINCTis a must