return nulls from double column join

B

Bosconian

I've been playing with this for hours. It seems like it should be simple,
but I can't figure it out.

I have two tables, table1 and table2. The first table has one column,
column1. The second table has two columns, column1 and column2. All are
number columns.

The data looks like this:

table1.column1

1
2
3
4

table2.column1 table2.column2

1 2

I need a query that will return values from table1.column1 that don't appear
in table2.column1 OR table2.column2. In the above example, this would be
values 3 and 4.

I can get null values from one column or the other, but not both.

Any help would be appreciated.
 
A

Andreas

You could try the following (untested):

select table1.column1 from table1 where table1.column1 NOT in (select
table2.column1 from table2) AND table1.column1 NOT in (select
table2.column2 from table2)

Regards,
Andreas
 
B

Bosconian

Andreas said:
You could try the following (untested):

select table1.column1 from table1 where table1.column1 NOT in (select
table2.column1 from table2) AND table1.column1 NOT in (select
table2.column2 from table2)

Regards,
Andreas

Andreas,

Your untested query worked perfectly. Very impressive! :-]

Chalk this one up for learning. Much appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top