本文介绍了在选择查询中插入子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个组"表和一个参与者"表.现在,我需要为每个组插入一个参与者.我将如何自动化呢?
I have a "Groups" table and a "Participants" table. Now I need to insert one Participant for each Group. How would I automate this?
INSERT INTO "Participants" ("Name", "FirstName", "GroupID") VALUES ("GENERIC", "GENERIC", GroupID)
应该为组"表中的每个组调用此插入,并将"GroupID"替换为相应的ID.
This Insert should be called for each Group in the Groups table, and the "GroupID" replaced with the corresponding ID.
这可以与子查询一起使用吗?
Would this work with a subquery?
谢谢,马丁
推荐答案
插入到选择中...
INSERT INTO
Participants
(
Name,
FirstName,
GroupID
)
SELECT
'GENERIC',
'GENERIC',
GroupID
FROM
Groups
这篇关于在选择查询中插入子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!