Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL插入到表中的行数超过一行_Sql_Sql Insert - Fatal编程技术网

SQL插入到表中的行数超过一行

SQL插入到表中的行数超过一行,sql,sql-insert,Sql,Sql Insert,我正在尝试使用子查询在表中插入两行 历史教学关系有(ID、课程ID、课时ID、学期、年份) ID、sec_ID、学期和年份都已设置,需要查找的是课程ID,因此我使用子查询查找它。仅子查询就有两个结果 我需要同时将这两行插入到表中,但不知道如何插入,因为这种插入只能产生一行结果 使用插入和选择: insert into HISTORYTEACHES select '2', course_id, '1', 'Spring', '2016' from HISTORYCOURSE where cour

我正在尝试使用子查询在表中插入两行

历史教学关系有(ID、课程ID、课时ID、学期、年份)

ID、sec_ID、学期和年份都已设置,需要查找的是课程ID,因此我使用子查询查找它。仅子查询就有两个结果


我需要同时将这两行插入到表中,但不知道如何插入,因为这种插入只能产生一行结果

使用
插入
选择

insert into HISTORYTEACHES
select '2', course_id, '1', 'Spring', '2016'
from HISTORYCOURSE 
where course_id like '2%'

顺便说一句,将值2插入
id
字段似乎很奇怪。也许这应该是自动递增的。如果这些是整数值,请删除单引号。

非常感谢!它起作用了!:)
insert into HISTORYTEACHES
select '2', course_id, '1', 'Spring', '2016'
from HISTORYCOURSE 
where course_id like '2%'