Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Select unmatched data from two columns


Select unmatched data from two columns

Author
Message
chgn01
chgn01
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1730 Visits: 1797
Comments posted to this topic are about the item Select unmatched data from two columns

--------------------------------------
;-)“Everything has beauty, but not everyone sees it.” ― Confucius
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)SSCertifiable (6.1K reputation)

Group: General Forum Members
Points: 6137 Visits: 25280
Thanks for a good question to start the week.

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
bochambers
bochambers
SSC-Enthusiastic
SSC-Enthusiastic (115 reputation)SSC-Enthusiastic (115 reputation)SSC-Enthusiastic (115 reputation)SSC-Enthusiastic (115 reputation)SSC-Enthusiastic (115 reputation)SSC-Enthusiastic (115 reputation)SSC-Enthusiastic (115 reputation)SSC-Enthusiastic (115 reputation)

Group: General Forum Members
Points: 115 Visits: 82
I've had to deal with this issue a lot, due to incomplete relationships in databases due to poor rules governing primary/foreign key relationships not being enforced. Another alternative is to use NOT EXISTS in a where clauses which from experience can be more efficient, particularly for relationships that aren't over a unique join condition. I hadn't looked at EXCEPT before and found it a useful comment and will see how it performs in the future.

Thanks.
Paul White
Paul White
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11112 Visits: 11353
I like this way of expressing the solution:


SELECT t1.ID FROM dbo.T1 AS t1
UNION
SELECT t2.ID FROM dbo.T2 AS t2
EXCEPT
SELECT t1.ID FROM dbo.T1 AS t1
INTERSECT
SELECT t2.ID FROM dbo.T2 AS t2;





Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Lokesh Vij
Lokesh Vij
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1716 Visits: 1599
Thanks for a good question to start the week!

~ Lokesh Vij

Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions

Link to my Blog Post --> www.SQLPathy.com

Follow me @Twitter


demonfox
demonfox
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1305 Visits: 1192
Too many queries , too many aliases ; I started to loose patience ...
but it said 2 correct , and found that initially ...

saved the day ..
an easy one to start the day..

~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one Ermm
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6293 Visits: 7190
Nice simple question regarding JOINS
Thanks, Gary.

____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18537 Visits: 13248
So much to read on a Monday morning :-)

I wonder why the explanation talks about EXCEPT when none of the answers use it.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Toreador
Toreador
SSCrazy
SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)SSCrazy (2.5K reputation)

Group: General Forum Members
Points: 2497 Visits: 8064
Koen Verbeeck (11/26/2012)
I wonder why the explanation talks about EXCEPT when none of the answers use it.


+1 ;-)
TomThomson
TomThomson
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11327 Visits: 12086
Nice basics question.

Odd sort of explanation though - maybe the author thought the references explained it well enough that he didn't need to say anything himself about why the actual answer is right and other options wrong. For the few people who got this wrong it might have been worth pointing out that any select statement of the general form
select col from something where col is null


can't return anything that isn't null, which immediately eliminates options 2,4,5 and 6, leaving only 1 and 3 as possibilities.

Tom

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search