gpt4 book ai didi

mysql - 序列化迁移 - 光标

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

是否可以在sequelize迁移中使用光标?我正在尝试创建 DML 脚本,其想法是循环表中的值,即。使用游标输入日期,然后将值插入到其他表中,即。光标内的膳食日。

table : day
dayId
dayName

table : meal
mealId
mealName

table : mealday
mealdayId
dayId
mealId

我应该在游标内使用的插入语句是:

insert into mealday (dayId,mealId) 
select **dayIdFromCursor**,mealId from meal

最佳答案

作为解决方法,我可以简单地重复 insert 语句 7 次(日表中的天数)并硬编码 dayId

insert into mealday (dayId,mealId) 
select 1,mealId from meal

insert into mealday (dayId,mealId)
select 2,mealId from meal

...

insert into mealday (dayId,mealId)
select 7,mealId from meal

关于mysql - 序列化迁移 - 光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31241909/

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