mysql - 从选择结果中执行插入查询到循环中
问题描述
我正在尝试从选择结果中执行插入查询到循环中。The problem is when I want to retrieve only one result from a select query that works correctly but when the select query retrieve more than one result that doesn't work.
GROUP_CONCAT 函数有问题吗?我该怎么做才能解决问题?
我在这里给你代码片段:
BEGIN
SELECT idJour INTO @idJour FROM `jour` WHERE JourSemaine = DayWeek;
SELECT GROUP_CONCAT(idTrancheH) AS result FROM tranchehoraire WHERE TrancheH BETWEEN heureDebut AND heureFin;
loop_label : loop
INSERT INTO `horaire` (`idEmployé`, `idJour`, `idTrancheH`) VALUES
(idEmployee,@idJour, @idTrancheH);
SET heureDebut = ADDTIME(heureDebut ,'0:30:00.00');
IF heureDebut <= TIME(heureFin) THEN
ITERATE loop_label;
ELSE
LEAVE loop_label;
END IF;
END LOOP;
RETURN heureDebut;
END
非常感谢
解决方案
推荐阅读
- apache-kafka - 在 KSQL Stream <- Table left join 中,部分事件未正确连接
- android - React-native 在 64 位设备上 - 调试工作正常但不发布。32位设备完全没问题
- google-cloud-platform - KAFKA Broker绑定外部IP
- c# - 理解为枚举赋值的结构
- sql - 左连接 OR 条件的替代方案
- swift - Xcode 11:无法从 iOS 13 上的自定义包中的资产目录(.car 文件)实例化图像
- python - 在 Odoo 13 中 @api.one 的替代品是什么?
- python - 获取数据框中匹配和不匹配列数据的计数
- javascript - 是否可以将某些单击的 href 发送到另一个 BrowserWindow?
- sql - 插入到 sql server 表中,使用返回超过 1 个值的子查询