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')
可以插入使用選擇命令 –