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

Matching Records and Other Conditions T-SQL

$
0
0

Hi Friends,

I have a small issue.I was writing one storeprocedure.... 

I have a table and on this I was writing couple of conditions.

Condition 1:

If three are mataching then display the records

Select * from Details 

where Category=@Category and SubCat=@Subcat and Name=@Name

If above condition is fail or if no data in the table 

then 

Condition 2:

select * from detail 

where Category=@Category or Subcat=@Subcat or Name=@Name (this is not perfect one what I need actually if category matches then display the records if not go Subcat if not go to Name)

Can anyone guide me how to do this ?

Thanks for your 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>