i understand that you might not see things like this right away. i thikn it's because you focus on the final results too much. you need to take this in small steps, like so:
ok, so i want to get a list of the people and their id numbers:
Code:
select t1.id
, t1.name
from myTable t1
i now want to eliminate rows that have an id number that matches any row in the name column, so i will start by matching those rows with a left outer join. i don't know how to filter them yet, but i know i will need to join the table, so let's just join the table first and see what i get:
Code:
select t1.id
, t1.name
, t2.id
, t2.name
from myTable t1
left outer
join myTable t2
on t1.id = t2.name
and when you get the results, you will see the pattern. but if you try to jump straight to the answer, it won't work.
how about this: when you look at this equation, can you tell me the expanded form in one step? (x-3)(x+2)(y+4) i bet not! you have to multiply out on pair, then the other. it's the same with SQL: you have to do step 1, then step 2. until you start breaking all of your problems down, you'll never see it.
Bookmarks