您好我想要合并两个表中的选定列并将这些值存储到另一个表中。
示例我有一个表名
class - classname location
和另一张表
student - studentid, name, classname
出勤 - 将两个表合并为仅选定的列。
i.e studentid , classname, location
告诉我如何将值插入到我的表格出勤中。
提前致谢...
答案 0 :(得分:3)
您应该使用INSERT...SELECT
INSERT INTO Attendance (studentid , classname, location)
SELECT s.studentid, c.classname, c.location
FROM class c
INNER JOIN student s ON c.classname = s.classname