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

If the value doesn't exist in a table, query another table. How to do that ?

$
0
0

I am using SQL Server 2012.
I have 2 tables, tblA and tblB that have the same columns with different data. Both have columns Symbol and Name.
I also have another table, tblC that has a column Symbol.

In a View (not stored procedure), I need to query tblC with tblA (join at column Symbol) where symbol = 'ABC', but if the Symbol 'ABC' doesn't exist in tblA, then query tblB with tblA (also join at column Symbol)  where symbol = 'ABC'.

How can I do that ?

Thank you.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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