A MySQL IF condition

database, if-statement, mysql

Solution

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

Problem

In my query I have an IF statement: ``` IF(friend.block, 'yes', 'no') ``` where friend.block value is 0 or 1.. but either way its putting 'yes'.. any idea?

Original source