Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Conditional join question

$
0
0

I am trying to write a query that requires that I join on multiple fields on two tables.  The problem I'm having is that I need to join on a field that can have a value that is treated as any by the application.  If I run my query without joining on the id field then it can return multiple values when it should return only one.  For example if I run this it could return one value or nothing

Select t1.* from table1 t1 join table2 t2 on t1.procedurecode = t1.procedurecode and t1.provider_id = t2.provider_id

If I run this:

Select t1.* from table1 t1 join table2 t2 on t1.procedurecode = t1.procedurecode

It could return

11111,9999

11111,12

Is there a way to handle the 9999 value in the join?  Thanks for anyones help.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>