kris1988edwards Posted December 22, 2014 Share Posted December 22, 2014 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? 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 Use a CASE statement in your select query. SELECT CASE WHEN tblWJC.WJCStatusID < 2 THEN 'Pre Production' WHEN tblWJC.WJCStatusID < 2 THEN 'In Production' ... Link to comment https://forums.phpfreaks.com/topic/293233-else-if-statement/#findComment-1500393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.