0
我想使用另一个查询的输出将多行插入到我的表中。使用另一个查询的结果将多行插入到数据库中
我的INSERT语句是这样的:
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')
可以插入使用选择命令 –