November 25, 2009 at 8:52 am
I have two tables, each with a 'town' column. How can I return rows form one table with non matching rows from the other
something like select * where tablea.town not equal to tableb.town
November 25, 2009 at 9:00 am
Can't help much without description about the tables / column names.
But let me give a try...
SELECT column list from table1 where town NOT IN (SELECT DISTINCT town FROM table2)
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
November 25, 2009 at 9:13 am
Before someone might suggest, let me tell you that you can also use Except clause.
SELECT town FROM table1
EXCEPT
SELECT town FROM table2
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
November 25, 2009 at 9:40 am
already tried that one, it seems to do the job. I wasnt aware of it as its new to sqls server
November 25, 2009 at 9:45 am
Is your problem solved, what do mean by "already tried that one"
Which one did you try already?
No clarity in either of your posts 😉
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
November 26, 2009 at 2:58 am
already tried the except clause
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply