I'm new to MySQL and I'm looking for some guidance. I have a table A,
with two columns X and Y with the following data:
| X | Y |
I want my SQL query to return "2" following this verbose logic: SELECT
DISTINCT X FROM A WHERE Y equals 25 and Y also does NOT equal 24.
I came up with the following SQL, which gives me my desired result,
but is there a better way to do it? Can it be achieved using MINUS or
BTW, I'm using IN here because I intend to replace the single numbers
(24 and 25) with arrays that have 0 to N members.
SELECT DISTINCT X FROM `A`
WHERE X IN (
SELECT X FROM `A` WHERE Y IN (25)
AND X NOT IN (
SELECT X FROM `A` WHERE Y IN (24)