I have the next SQL code:
DELIMITER $$
CREATE PROCEDURE `test`.`new_procedure` (queryString VARCHAR(255))
BEGIN
SELECT @tempValue = COUNT(*) FROM test.userdata_extended WHERE inn LIKE queryString;
IF @tempValue > 0 SELECT * FROM test.userdata_extended WHERE inn LIKE queryString;
END $$
I'm putting the COUNT* result into @tempValue variable.
Then I'm trying to compare it for being greater than zero.
I'm getting error with the statement comparing process. MySQL reports me a UNEXPECTED SELECT SYM error. What does it mean?
Also this would be a check for another tables. I need IF-ELSE statements, because basing on several query result my procedure must return the exact code error value (which could be different) for the my developed application to handle or giving the data, if all is fine.
How to fix this issue?
Thanks
解决方案
You have forgot the THEN in your if statement. You need to add the THEN.
Like this:
IF @tempValue > 0 THEN ...your statement
END IF;
You have also forgot to add the END IF; add this also.