troubleshooting Question

SQL Join

Avatar of nutnut
nutnutFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL Server.NET ProgrammingSQL
18 Comments4 Solutions170 ViewsLast Modified:

I have 2 tables.

TblA  Col1, Col2, Col3

TblB Col1, Col2, Col3

I need to join them BUT....

I need to return a row if ALL 3 Cols equal.

Col1= Col1
and Col2 = Col2
and Col3 = Col3


If ALL 3 Cols do NOT equal but

Col1 = Col1
and Col2 = Col2
and Col3 <> Col3

then return that row instead

So its sort of a double pass.  First pass is "do all 3 cols equal" if not "do Cols 1 & 2 equal", if not return nothing.

I am stumped, please help



Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 18 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 18 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros