由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 我的这句MySQL哪里错了吗?
相关主题
mysql的问题请教sql server 2005,怎样在固定时间run stores procedure
再来一个SQL Server的面试题A sql question
一个SQL写法性能的请教再请教一个问题:stored procedure能不能直接显示信息什么的? (转载)
PIVOT, 请大拿,帮我debugmysql: how to format output?
[Mysql] how to return NULL count in group by query (转载)誰來解釋一下這是什麼原理
请教怎么来log duration of a MYSQL procedure?any informix high hand here? sql need help here.
【签名】支持yunmeng办mysql讲座的mysql C API
CINAOUG/CINASSUG MySQL 2013讲座问个查询的问题
相关话题的讨论汇总
话题: pretime话题: select话题: null话题: procedure话题: time
进入Database版参与讨论
1 (共1页)
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));

1 (共1页)
进入Database版参与讨论
相关主题
问个查询的问题[Mysql] how to return NULL count in group by query (转载)
#在SQL里啥子意思请教怎么来log duration of a MYSQL procedure?
请问mysql 里如何创建超宽表【签名】支持yunmeng办mysql讲座的
【MYSQL server里能不能写stored procedure?】CINAOUG/CINASSUG MySQL 2013讲座
mysql的问题请教sql server 2005,怎样在固定时间run stores procedure
再来一个SQL Server的面试题A sql question
一个SQL写法性能的请教再请教一个问题:stored procedure能不能直接显示信息什么的? (转载)
PIVOT, 请大拿,帮我debugmysql: how to format output?
相关话题的讨论汇总
话题: pretime话题: select话题: null话题: procedure话题: time