在 mysql 命令提示符下,我运行:
SELECT EXISTS (SELECT 1 FROM test1 WHERE name1 like '%Nadiya%')
返回
EXISTS (SELECT 1 FROM test1 WHERE name1 like '%Nadiya%')
1
但以下过程不会打印为存在。我需要进入 IF 语句。请让我知道什么变化可以让我进入 IF。
DELIMITER //
CREATE PROCEDURE verifyAndUpdate30(in searchName varchar(12), in searchId bigint, inout result int)
BEGIN
IF ( SELECT EXISTS (SELECT 1 FROM test1 WHERE name1 like '%searchName%') ) THEN
SELECT 'EXISTS';
UPDATE TEST SET testFlag=1 WHERE id=searchId;
SET result=1;
ELSE
SELECT 'DOES NOT EXISTS';
END IF;
SELECT result;
END
//
DELIMITER ;
调用程序:
SET @increment = 0;
call verifyAndUpdate30('Nadiya', 5532, @increment);