d********t 发帖数: 9628 | 1 if (select @pretime is null) then
set @pretime := time(0);
end if;
总说我syntax error. |
y*****g 发帖数: 677 | 2 You may need wrap your statements in a block of function/procedure like this:
delimiter $$
drop procedure if exists a;
create procedure a ()
begin
set @pretime = null;
if (@pretime is null) then
set @pretime := time(0);
end if;
select @pretime;
end $$
delimiter ; |
d***e 发帖数: 793 | 3 我试了yunmeng的reply,好像不work。
我觉得问题好像在于user defined variable can't be used as a value and
assigned value in the same statement。if statement is one statement after
all
这样就没问题了:
SELECT IFNULL(@PRETIME, TIME(0)); |
d********t 发帖数: 9628 | 4 if (select @pretime is null) then
set @pretime := time(0);
end if;
总说我syntax error. |
y*****g 发帖数: 677 | 5 You may need wrap your statements in a block of function/procedure like this:
delimiter $$
drop procedure if exists a;
create procedure a ()
begin
set @pretime = null;
if (@pretime is null) then
set @pretime := time(0);
end if;
select @pretime;
end $$
delimiter ; |
d***e 发帖数: 793 | 6 我试了yunmeng的reply,好像不work。
我觉得问题好像在于user defined variable can't be used as a value and
assigned value in the same statement。if statement is one statement after
all
这样就没问题了:
SELECT IFNULL(@PRETIME, TIME(0)); |
d********t 发帖数: 9628 | 7 Thanks!
【在 d***e 的大作中提到】 : 我试了yunmeng的reply,好像不work。 : 我觉得问题好像在于user defined variable can't be used as a value and : assigned value in the same statement。if statement is one statement after : all : 这样就没问题了: : SELECT IFNULL(@PRETIME, TIME(0));
|