gpt4 book ai didi

Mysql 截断了函数中不正确的 DOUBLE 值

转载 作者:行者123 更新时间:2023-11-29 16:34:14 26 4
gpt4 key购买 nike

我搜索并知道这个问题已经被问过很多次了,但我的似乎有所不同。我没有使用 update 也没有使用 and。由于下面的测试,我称其为“in function”,我真的很困惑。

功能中:

drop function if exists `login_t`;
create function `login_t`()
returns bool
begin
declare `pw` varchar(32);
set `pw` = '4297f44b13955235245b2497399d7a93';
return if(pw, pw = MD5(CONCAT('123', '123')), false);
end;
select login_t(); -- > Truncated incorrect DOUBLE value: '4297f44b13955235245b2497399d7a93'

过程中:

drop procedure if exists `login_t2`;
create procedure `login_t2`()
begin
declare `pw` varchar(32);
set `pw` = '4297f44b13955235245b2497399d7a93';
select if(pw, pw = MD5(CONCAT('123', '123')), false);
end;
call login_t2(); -- 1

最佳答案

看起来当您从函数返回 bool 值时,这些值应该是数字。 MySQL 尝试将 if 函数的第一个参数 (pw) 转换为数值,但失败。

您可以使用代码:

create function `login_t`()
returns boolean
begin
declare `pw` varchar(32);

set `pw` = '4297f44b13955235245b2497399d7a93';

if (pw = MD5(CONCAT('123', '123'))) then
return true;
else
return false;
end if;
end;

关于Mysql 截断了函数中不正确的 DOUBLE 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53704059/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com