mysql 作业 定时执行存储过程
mysql中的事件是不是相当于MSSQL中的作业,能定时执行存储过程?如果是的话,一个事件中能不能像MSSQL中的作业一样,执行多个存储过程?另外,mysql的存储过程中...
mysql中的事件是不是相当于MSSQL中的作业,能定时执行存储过程?
如果是的话,一个事件中能不能像MSSQL中的作业一样,执行多个存储过程?
另外,mysql的存储过程中调用另一个存储过程怎么做?
DECLARE firsttime datetime;
select firsttime = (select n_Record_Date from ((select * from t_Record where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1) union (select * from t_RecordLs where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1)) as temp order by n_Record_Date limit 0, 1);
这个语句哪里错了?
(select n_Record_Date from ((select * from t_Record where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1) union (select * from t_RecordLs where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1)) as temp order by n_Record_Date limit 0, 1)是从两张联合以来的表里读取第一条记录的一个字段。
然后把读取到的字段赋值给firsttime。 展开
如果是的话,一个事件中能不能像MSSQL中的作业一样,执行多个存储过程?
另外,mysql的存储过程中调用另一个存储过程怎么做?
DECLARE firsttime datetime;
select firsttime = (select n_Record_Date from ((select * from t_Record where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1) union (select * from t_RecordLs where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1)) as temp order by n_Record_Date limit 0, 1);
这个语句哪里错了?
(select n_Record_Date from ((select * from t_Record where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1) union (select * from t_RecordLs where s_Device_IP = '192.168.1.153' and n_Record_Type in (1, 2) order by n_Record_Date limit 0, 1)) as temp order by n_Record_Date limit 0, 1)是从两张联合以来的表里读取第一条记录的一个字段。
然后把读取到的字段赋值给firsttime。 展开
2个回答
展开全部
具体怎么用我不清楚,事件是相当于mssql的作业
下面是调用存储过程
delimiter //
drop procedure if exists up_t1;
create procedure up_t1()
begin
select 'hello world';
end
;
create procedure up_t2()
begin
call up_t1();
select 'hello world2 ';
end;
//
下面是调用存储过程
delimiter //
drop procedure if exists up_t1;
create procedure up_t1()
begin
select 'hello world';
end
;
create procedure up_t2()
begin
call up_t1();
select 'hello world2 ';
end;
//
追问
哦,谢谢,摸索了半天搞明白了。另外有个问题问一下。字数多,写不下,看上面补充问题。
追答
select (xxxx) into firsttime;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询