【发布时间】:2017-03-19 00:54:06
【问题描述】:
我想使用另一个查询的输出将多行插入到我的表中。
我的插入语句如下所示:
INSERT INTO group_messages (group_message_text,group_message_group_id,group_message_user_id)
VALUES ('Rounded ended! Hit the standings button in the top right corner to check your score.','$group_id','0')
这里$group_id 需要填充,但是从该查询返回的group_ids:
SELECT group_id
FROM groups
第二个查询现在返回3 group_ids: 1, 2, 3
因此,这应该导致类似:
INSERT INTO group_messages (group_message_text,group_message_group_id,group_message_user_id)
VALUES ('Rounded ended! Hit the standings button in the top right corner to check your score.','1','0'), ('Rounded ended! Hit the standings button in the top right corner to check your score.','2','0'), ('Rounded ended! Hit the standings button in the top right corner to check your score.','3','0')
【问题讨论】:
-
可以使用插入选择命令
标签: mysql