You might also consider investigating the use of the ISNULL() function It won't return 0 or 1... it'll return 0 or the value...
ie SELECT s.speciesID, s.speciesName, ISNULL(sf.speciesFusionID, "0") as speciesFusionID FROM uoaSpecies s LEFT JOIN uoaSpeciesFusion sf ON (s.speciesID = sf.speciesID AND sf.coID = #url.coID#) This replaces the value of speciesFusionID with 0 ONLY if speciesFusionID is actualy null. Rick Paul Giesenhagen wrote: > I have a MySQL query that works great, but the IF statement I can't get to > work in MS SQL ... anyone dare to help out > > SELECT s.speciesID, s.speciesName, > IF(sf.speciesFusionID IS NULL, "0", "1") > FROM uoaSpecies s > LEFT JOIN uoaSpeciesFusion sf > ON (s.speciesID = sf.speciesID AND sf.coID = #url.coID#) > > <!---- This is the problem line ---> > IF(sf.speciesFusionID IS NULL, "0", "1") > > Basically if speciesFusionID IS NULL then I want speciesFusionID to be 0 if > it isn't, I want it to be 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:242195 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54