存储过程中的selectintofrom是干什么的

存储过程中的selectintofrom是干什么的

2023年6月23日发(作者:)

存储过程中的selectintofrom是⼲什么的select into 赋值:select 0 into @starttimeselect @starttime from DUAL

into后边应该还有个变量名,into前⾯也还要带上筛选字段,例如select count(*) into v_count from dual;这条语句的意思是查询dual表的所有记录数,将查询结果存⼊v_count变量中,也就是给变量设值的⽤法可以给变量赋值CREATE PROCEDURE cp_p_recived ()BEGINSELECTIFNULL(MAX(recived_time), 0) INTO @starttimeFROMp_recived_before;DELETE FROM p_recived_before;INSERT INTO p_recived_before (user_id,recived_time,recived_count,create_time,city_id) _id,d_time,d_count,_time,_idFROM(SELECT(

SELECTuser_idFROMaddrdb.w_contactsWHEREphone = er_mobileLIMIT 1) AS user_id,_date AS recived_time,1 AS recived_count,unix_timestamp(now()) * 1000 AS create_time,receiver_city_id AS city_idFROMtmsdb.w_waybill _date > @starttimeAND w. STATUS = 200ORDER _date ASCLIMIT 2000) cp;SELECT IFNULL(MAX(recived_time), 0) INTO @mymaxtime FROM p_recived_before;INSERT INTO p_recived (user_id,recived_time,recived_count,create_time,city_id) _id,d_time,d_count,_time,_idFROM(SELECTuser_id,recived_time,recived_count,create_time,city_id,MAX(recived_time)FROMp_recived_before WHERE user_id is NOT NULL

GROUP BYuser_id) pr

LEFT JOIN (SELECTuser_idFROMp_recivedWHEREcreate_time >= UNIX_TIMESTAMP(CAST(SYSDATE() AS DATE)) * 1000AND create_time < UNIX_TIMESTAMP(CAST(SYSDATE() AS DATE) + 1) * 1000) p ON _id = __id > 0AND _id > 0AND _id IS NULL;

DELETEFROMp_recived_before;INSERT INTO p_recived_before (recived_time) VALUES (@mymaxtime);ENDselect * from tmsdb.w_waybill w where receiver_id='KH171'

发布者:admin,转转请注明出处:http://www.yc00.com/news/1687517079a16313.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信