Oracle Multi-Table Association update

Source: Internet
Author: User

Drop table Course;create table course (ID integer,teacherno integer,teacherdesc varchar2 (+), TeacherName varchar2 (50), Coursename varchar2); INSERT into course values (1,100, ' Mr.zhang ', ' Zhangsan ', ' 中文版 '); INSERT into course values ( 2,101, ' Mr.wang ', ' Wangwu ', ' history '), insert into course values (2,101, ' Mr.wang ', ' Wangwu ', ' Chinese '); update course set Teacherdesc= ' Good Teacher ' where Teacherno=101;commit;drop table Teacher;create table Teacher (ID integer,teacherdesc VARCHAR2, TeacherName varchar2 (), insert into teacher values ("Mr.zhang", "Zhangsan"); insert into teacher VALUES (101, ' Mr.wang ', ' Wangwu '); update teacher set teacherdesc= ' excellent teacher ' where id=101;commit;select C.teacherdesc, C.teachername, T.teacherdesc, t.teachername from course C, teacher t where C.teacherno = T.id and (C.tea Cherdesc! = T.TEACHERDESC or C.teachername! = t.teachername); update course C Set (C.teacherdesc, C.teachername) =       (Select T.teacherdesc, T.teachernameFrom teacher T whereC.teacherno = T.id and (c.teacherdesc! = T.TEACHERDESC or C.teachername! = t.teachername)) Where exists (select 1 from teacher T whereC.teacherno = T.id and (c.teacherdesc! = T.TEACHERDESC or C.teachername! = t.teachername)); Commit;select C.teacherdesc, C.teachername, T.teacherdesc, t.teachername from course C, teacher t where C.teacherno = t . ID and (C.teacherdesc! = T.TEACHERDESC or C.teachername! = t.teachername); Select C.teacherdesc, C.teachername, T.teache Rdesc, T.teachername from course C, teacher t where C.teacherno = t.id;

  

Oracle Multi-Table Association update

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.