in my query i have IF(friend.block, 'yes', 'no') and friend.block value is 0 or 1.. but eaither way its putting 'yes'.. any idea?
A:
Reference: MySQL Reference
The syntax is:
IF (friend.block = 1) THEN
'Yes'
ELSE
'No'
END IF
You can use case statement:
CASE friend.block WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' END
Kirtan
2009-10-12 12:34:43
Still doesn't explain why his if function didn't work, see: http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if
Andre Miller
2009-10-12 12:36:34
+3
A:
friend.block
should be of type INTEGER
for that to work or you have to put a comparaison there:
IF(friend.block != 0, 'yes', 'no)
najmeddine
2009-10-12 12:36:21