This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / Oracle SQL Question
-brother-pooh(Pooh哥哥);
2007-8-15
{2711}
(#3871120@0)
-
cannot you do something like insert into CourseStudent select Course .Course,NewStudents .StudentName from NewStudents ,Course ?
-win(秋天的菠菜);
2007-8-15
(#3871128@0)
-
Thanks for quick reply. Would you mind give a sql? Not quite get your idea. Thanks anyway.
-brother-pooh(Pooh哥哥);
2007-8-15
(#3871136@0)
-
isn't "insert into CourseStudent select Course .Course,NewStudents .StudentName from NewStudents ,Course" a SQL ?
-win(秋天的菠菜);
2007-8-15
(#3871146@0)
-
Great! You're right, it is the answer. I sort of transformed it a little bit. Thanks a lot. :)Select Course, StudentName From CourseStudent
Union
select Distinct CourseStudent.Course,NewStudents.StudentName
From NewStudents ,CourseStudent
Order by 1,2
;
-brother-pooh(Pooh哥哥);
2007-8-15
{165}
(#3871167@0)
-
这么说你没有course表?那么就用子查询做一张。你的第二个子查询有可能有效率问题,因为旧表可能较大,你用CROSS JOIN会产生巨大数字。改进如下:Select Course, StudentName From CourseStudent
Union
select course.Course,NewStudents.StudentName
From NewStudents ,(SELECT DISTINCT course FROM coursestudent) course
Order by 1,2
;
-newkid(newkid);
2007-8-15
{186}
(#3871199@0)
-
Now it's perfect! Thanks a lot! :)
-brother-pooh(Pooh哥哥);
2007-8-15
(#3871206@0)