![](/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.