troubleshooting Question

Case Statement in Where Clause

Avatar of lbarnett419
lbarnett419 asked on
Microsoft SQL Server
10 Comments1 Solution320 ViewsLast Modified:
I have 2 tables where I need to select records if the identifiers can be joined. There are 2 sets of identifiers...I want to compare the first ones and if they join, then select the record. If they don't match, try to join on the second identifier. If that doesn't work, then the record isn't selected.

Do I use a case statement in the where clause?

Select a.stateid1, b.stateid2, a.ssn1,b.ssn2, a.lastname,a.firstname
from tablex a, tabley b
case a.stateid1= b.stateid2
then end?
else a.ssn1=b.ssn2
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
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 1 Answer and 10 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