【发布时间】:2019-12-24 11:38:35
【问题描述】:
我想在我的表中插入行,如下所示: 我的栏目是学生、学科、班级、教师、水平。主键是 (student,subject)。该表包含所有学生,但其中一些学生缺少数学科目,所以我想添加它而不复制已经拥有它的学生。
我已经尝试过了,但它违反了唯一约束:
insert into table (student,subject,class,teacher,level)
select a.student, 'math', null, null, null
from table a
where a.student in (select distinct student from table where subject not in 'math')
and (a.student,a.subject) not in (select student,subject from table);
【问题讨论】:
标签: sql oracle sql-insert