kris1988edwards Posted December 22, 2014 Share Posted December 22, 2014 (edited) Good morning, I am trying to return specific values depending on the value of the WJCStatusID, for example if WJCStatusID = < 4 but > 2 return "In production" SQL QUERY: SELECT tblWJCItem.AddedDescription, tblWJC.WJCPrefix + Convert(Varchar(10),tblWJC.WJCNo) AS OurRef, tblWJCItem.MaterialName, tblStockFamily.StockFamily, tblWJCItem.WeightToSend, tblWJC.DateCreated, tblWJC.WJCStatusID FROM tblWJC INNER JOIN tblWJCItem ON tblWJC.WJCID = tblWJCItem.WJCID INNER JOIN tblStockFamily ON tblWJCItem.ProductFamilyID = tblStockFamily.StockFamilyID IF (tblWJC.WJCStatusID) < 2 THEN 'Pre Production' ELSE IF (tblWJC.WJCStatusID) < 4 THEN 'In Production' ELSE IF (tblWJC.WJCStatusID) > 4 THEN 'Ready To Ship' ELSE 'Awaiting Lab Results'; I am quite new to the world of mssql so I maybe doing something wrong which is quite simply to fix. Can any body help? Edited December 22, 2014 by kris1988edwards Quote Link to comment https://forums.phpfreaks.com/topic/293233-else-if-statement/ Share on other sites More sharing options...
kicken Posted December 22, 2014 Share Posted December 22, 2014 (edited) Use a CASE statement in your select query. SELECT CASE WHEN tblWJC.WJCStatusID < 2 THEN 'Pre Production' WHEN tblWJC.WJCStatusID < 2 THEN 'In Production' ... Edited December 22, 2014 by kicken Quote Link to comment https://forums.phpfreaks.com/topic/293233-else-if-statement/#findComment-1500393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.