gpt4 book ai didi

Mysql - 打印@loop_start_date到@loop_end_date之间的所有值

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

我正在尝试:

1. 打印@loop_start_date@loop_end_date之间的所有值
2. loop_start_date 应在此处增加 1,直到 loop_start_date=loop_end_date

我尝试了下面,但 Mysql 说

     #1064 - You have an error in your SQL syntax; check the manual that 
corresponds to your MySQL server version for the right
syntax to use near 'BEGIN Declare @user_id int' at line 3

这是程序代码

CREATE PROCEDURE generatePayscale

BEGIN
Declare @user_id int;
Declare @office_id int;
Declare @loop_start_date Date;
Declare @loop_end_date Date;
SET @user_id = 1287;
SET @office_id = 8;
SET @loop_start_date = '2018-06-02';
SET @loop_end_date = '2018-06-06';


WHILE(@loop_start_date < @loop_end_date) do
SELECT old_paysetupid
FROM personneltransfer personnelid=@user_id
AND pt.transferdate>@loop_start_date
END WHILE;
END

最佳答案

这可能会为您指明正确的方向,我会改变一些事情。添加了BEGIN。然后为每个变量添加声明。然后你需要在 from 后面加上 where

SET @user_id = 1287;
SET @office_id = 8;
SET @loop_start_date = '2018-06-02';
SET @loop_end_date = '2018-06-06';

WHILE(@loop_start_date < @loop_end_date) do
BEGIN
SELECT old_paysetupid
FROM personneltransfer where personnelid=@user_id
and pt.transferdate>@loop_start_date
END WHILE;

关于Mysql - 打印@loop_start_date到@loop_end_date之间的所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50916767/

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