Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Using OR in a IF statement

$
0
0

I am fairly now to SQL and using stored procedures so if this is I am sorry about the noob question.

I have a stored procedure that is trying to find items that fit into 1 of 3 categories but there are many different item groups within each category. So what I was trying to do was use IF statements to identify each item.

The code I was trying was:

SQL
IFSUBSTRING(@exactitem,1,2)=('EP'OR'AC')BEGINSELECTFMTITEMNO,SEGMENT1,SEGMENT2,SEGMENT3,SEGMENT4,SEGMENT5FROMdbo.Table1WHERESEGMENT1=@GROUPANDSEGMENT3=@COLORANDSEGMENT5=@STYLEANDSEGMENT4=@MATERIALRETURN(1)END

Is this even possible and I just have the syntax wrong or will I need to try a different approach?


Viewing all articles
Browse latest Browse all 4871

Trending Articles



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