![](/img/trans.png)
[英]How to take where clause conditions from table column in oracle SQL or plsql
[英]how to use insert statement with where clause from diff table in oracle without using plsql
我想像下面这样插入
If
select *from class where student_name='A' ;
then
Insert into student (Studnetname varchar2,rollno integer) values('A',1);
不使用 PL/SQL
那岂不是那么简单
insert into student (studentname, rollno)
select student_name, rollno
from class
where student_name = 'A'
and rollno = 1;
如果存在这样的学生(其值满足WHERE
子句),则将插入一行。 否则,什么都不会发生。
我想要没有 select 的直接插入语句
最接近满足此要求的是:
Insert into student (Studnetname, rollno)
select 'A',1
from dual
where exists (select null from class where student_name = 'A' )
;
如果 CLASS 中至少有一条记录与给定条件匹配,这将在 STUDENT 中插入一行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.