troubleshooting Question

How to place on condition on a select statement to use certain tables

Avatar of johndeerb
johndeerb asked on
MySQL ServerMicrosoft SQL Server 2005SSRS
9 Comments2 Solutions226 ViewsLast Modified:
I am a newbie to sql. I am needing to show the vst_int_id's if the diag_ty='P' then use Table3 or if the diag_ty='S' then use Table4. I am not sure where to go from here to get the results that I need.

SELECT Table1.vst_int_id, Table1.diag_ty, Table2.diag_ds,
Table3.HtFcode, Table4.LVADcode
Table2 ON Table1.diag_int_id = Table2. Diag_int_id INNER JOIN
Table3.HtFcode ON Table2.diag_code = Table3.HtFcode INNER JOIN
Table4.LVADcode ON
Table2.diag_code = Table4.LVADcode  

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

Join our community to see this answer!
Unlock 2 Answers and 9 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 2 Answers and 9 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