Select rows where value of second column is not present in first column
For the simple case of a single given id1:
SELECT DISTINCT x.id2   -- DISTINCT only needed if there are dupes
FROM   tbl x
WHERE  x.id1 =  @a
AND    x.id2 &lt;&gt; @a;

Generally, there are basically four techniques to do what you are after. Both columns could just as well be in different tables, almost the same problem.
NOT EXISTS
SELECT DISTINCT x.id2 
FROM   tbl x
WHERE  &lt;some condition&gt;
AND    NOT EXISTS (
    SELECT FROM tbl y
    WHERE  &lt;some condition&gt;
    AND    y.id1 = x.id2
    );

LEFT JOIN / IS NULL
SELECT DISTINCT x.id2 
FROM   tbl x
LEFT   JOIN tbl y ON y.id1 = x.id2
                 AND &lt;some condition for y&gt;
WHERE  &lt;some condition for x&gt;
AND    y.id1 IS NULL

EXCEPT
SELECT DISTINCT id2
FROM   tbl
WHERE  &lt;some condition&gt;

EXCEPT ALL            -- ALL to make it faster - no dupes left after DISTINCT
SELECT tbl.id1
FROM   tbl
WHERE  &lt;some condition&gt;

NOT IN
SELECT DISTINCT x.id2 
FROM   tbl x
WHERE  &lt;some condition&gt;
AND    x.id2 NOT IN (
    SELECT DISTINCT id1
    FROM   tbl y
    WHERE  &lt;some condition&gt;
    );

You'll have to test which one is fastest for you. Benchmarks disagree. It depends on data distribution and other details. NOT IN rarely wins. It's mostly one of the first two.
As @ypercube commented: if (id1, id2) is unique, the DISTINCT clause is not needed - except the one in the NOT IN sub-query, which is meant to help performance.
Related answer with more details for PostgreSQL on SO:

Select rows which are not present in other table