Home > database > DB2 database, how to use the update statement in the nested use inner join is updated.
DB2 database, how to use the update statement in the nested use inner join is updated.
Time:09-18
In the student table insert the following data: XH XM XB CSRQ BJ Wang2 xiao3 ming2 male 1990-08-01 1 001 002 zhang SAN fung female 2 1988-04-15 003 Anthony lau kwok leung male 1992-02-14 2 004 xiao-qiang liu male 1991-01-28 1 005 wei-wei zhu female 1993-06-12 1 Insert the following data in the score table: XH YW SX YY 001, 78, 96, 56 002, 89, 59, 97 003 90 76 88 59, 004, 92, 100 34 65 91 005
I want to have "zhang SAN feng" YW achievement to 89, using the update nested statements Upadate scrore set score. YW=99 where score. XH=(select student. XH from student where the student. The XM="zhang SAN feng") can be achieved, But I don't want to use nested statements, want to use the inner join, through the following several attempts, failed, 1. Db2 "update score set score. YW=89 from score, student where score. XH=student. XH and student. The XM='zhang SAN feng" 2. Db2 "update score set score. YW=89 from score inner join student on score. XH=student. XH and student. The XM='zhang SAN feng" 3. Db2 "update score inner join student on score. XH=student. XH set score. YW=89 where student. XM='zhang SAN feng" 4. Db2 "update score inner join student set score. YW=89 on score. XH=student. XH where student. XM='zhang SAN feng" Of these four is not successful, where is the problem, how to correctly use upadate inner sleeve join!
CodePudding user response:
Use this:
The update score set score. YW=89 from student where score. XH=student. XH and student. The XM='zhang SAN feng'