I am trying to make this IF statement work, but I can’t seem to make it do what I want. If I do a select @result, It’ll give me the value 0, then why doesn’t the IF statement work?
SET @message = '((sometihng here))';
select LEFT(@message, 1) into @firstChar;
select STRCMP(@firstChar,'(') into @result;
IF (@result = 0) THEN
SET @message = 'true';
//more selects and cals here;
END IF;
select @message;
I should get true, but I don’t it shows me an error:
SQL query: IF( @result =0 ) THEN SET @message = 'true';
MySQL said:
1064 – You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ‘IF (@result = 0) THEN SET @message = ‘true” at line 1
try use function http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_if