-
Hi,
I have two tables student and student_grades
student
=======
Opm_oid NUMBERm (p.k.)
NAME VARCHAR(50)
student_grades
==============
opm_aid NUMBER (p.k.)
opm_oid NUMBER (f.k.)
GRADE VARCHAR(5)
My question is as follows :-
This is my insert statement for student
insert into student (Opm_oid, NAME) values
(10, 'BAKER');
Now I want to insert student_grades
in one single sql statement using insert with
select, I need to find
the value 'Opm_oid' for BAKER from the student
table and insert into student_grades along with
other values.
Can something like this will work ?
insert into student_grades (opm_aid, grade,
opm_oid) values ('3', 'A+', select opm_oid from
student where name = 'BAKER');
Please let me know what is the correct way to
do this, I don't want to use procedures for
performance issues.
Thanks.
Sincerely,
Viji
-
insert into student_grades (opm_aid, grade,
opm_oid)
select '3', 'A+', opm_oid
from student
where name = 'BAKER' ;
-
Thanks for your reply,
it works fine.
Viji
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|