我是MySql的新手。
为什么在下面的代码段中没有执行阻止?
declare row_exist int;
select count(id) into row_exist from country where name='japan';
if(row_exist = 1) then
signal sqlstate '45000'
set message_text = 'Error = Duplicate country found !';
end if;
这是有效的
declare row_exist int;
select count(id) into row_exist from country where name='japan';
if(row_exist >= 0) then
signal sqlstate '45000'
set message_text = 'Error = Duplicate country found !';
end if;
日本'只有一个条目。