December 4, 2008 at 10:05 am
I have the follow SQL:
SELECT DISTINCT t1.Col1, t2.Col1
FROM Table1 t1 LEFT OUTER JOIN Table2 t2
ON (t1.Col1 = t2.Col2)
When I run it, I expect , and get the following
t1.Col1 t2.Col1
Data1 Data1
Data2 Data2
Data3 NULL
Data4 NULL
Data5 Data5
What I'm trying to achieve is just the rows which have the NULLS in the second table, like in the following example:
Data3 NULL
Data4 NULL
But when I entered it
and t2.Col1 = NULL
I get:
t1.Col1 t2.Col1
Data1 NULL
Data2 NULL
Data3 NULL
Data4 NULL
Data5 NULL
ANY SUGGEESTIONS???
December 4, 2008 at 10:09 am
try writing it like this;
SELECT DISTINCT t1.Col1, t2.Col1
FROM Table1 t1 LEFT OUTER JOIN Table2 t2
ON (t1.Col1 = t2.Col2)
WHERE t2.Col1 is NULL
December 4, 2008 at 10:09 am
You need to put the t2.col1 is null in a where clause not in the join condition like this:
SELECT DISTINCT t1.Col1, t2.Col1
FROM Table1 t1 LEFT OUTER JOIN Table2 t2
ON (t1.Col1 = t2.Col2)
Where
t2.Col2 is null
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply