February 23, 2006 at 9:54 am
Is it possible to use an If within a SQL statement?
The sort of thing I am after is:
Select fieldName1, fieldName2, (if fieldName3 is Null return False else return True) as fieldValue From table Where fieldName5 = 2
Is this possible?
Cheers,
Julian
February 23, 2006 at 9:59 am
CASE WHEN fieldname3 IS NULL THEN 'False' ELSE 'True' END As fieldvalue
February 23, 2006 at 10:01 am
You beat me to it PW..
February 23, 2006 at 10:17 am
Excellent, thanks for that.
Is it possible to return boolean values as opposed to the text values True and False?
February 23, 2006 at 10:27 am
Use this:
CASE WHEN fieldname3 IS NULL THEN 0 ELSE 1 END As fieldvalue
February 23, 2006 at 10:31 am
Perfect, thanks.
February 24, 2006 at 10:39 am
The answer is "no", you cannot use an if statement in a select!
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply