I have this table structure:
id1 id2
1 2
1 3
1 4
2 1
2 5
I need to build a SQLquery to select id2id2
where id1id1
is not in id2id2
. For example if id1 = 1id1 = 1
then only id2=3id2=3
and id2=4id2=4
. Any help? I try with
I tried this one:
SET @a=1;
SELECT DISTINCT x.id2
FROM tt x, tt y
WHERE x.id1=@a AND x.id1 != y.id2;
but itsn'tit's not working.