我有一个select语句,它获取100行数据并将其插入表中。但是,我想插入以将1
插入另一列,以便我在相邻列中插入所有行。
这是我的插入选择语句
insert into examination_data (ed_cs_id,ed_examination_id)
VALUES ((
select cs_id
from class_students
where cs_class_id = 1 AND cs_year_id = 1 ),1);
在运行查询时,我收到错误
/ * SQL错误(1242):子查询返回多于1行* /
答案 0 :(得分:0)
insert into examination_data (ed_cs_id,ed_examination_id)
select cs_id,1
from class_students
where cs_class_id = 1 AND cs_year_id = 1;
答案 1 :(得分:0)
试试这个
insert into examination_data (ed_cs_id,ed_examination_id) (select cs_id,1 as "COLUMN_NAME" from class_students where cs_class_id = 1 AND cs_year_id = 1);