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'


Welcome to come to my blog: " ,

CodePudding user response:

1/f,
reference Dong Xuyang TonyDong response:
use this:
 
The update score set score. YW=89 from student where score. XH=student. XH and student. The XM='zhang SAN feng'


Welcome to come to my blog: " ,

No, not working correctly.
DB21034E The command was processed as an SQL statement because it was not a
Valid Command Line Processor Command. During SQL processing it returned:
SQL0103N The numeric literal "89 from student where score" is not valid.
SQLSTATE=42604,
I will use the update, I am just want to update the nested inside inner join for the update

CodePudding user response:

I mean, run the following command:
 

Db2 "update score set score. YW=89 from student where score. XH=student. XH and student. The XM='zhang SAN feng"



You compare, this is the update use inner join the wording,

CodePudding user response:

The
reference 3 floor Dong Xuyang TonyDong response:
I mean, run the following command:
 

Db2 "update score set score. YW=89 from student where score. XH=student. XH and student. The XM='zhang SAN feng"



You compare, this is the update use inner join writing,
run results error

CodePudding user response:

I use the development tools to perform the update statement above is successful, the db2 SQL statements directly to connect to the database?
 
Db2=& gt; Connect to HRDB user db2inst1 using XXXXXX

The Database Connection Information

The Database server=DB2/LINUXX8664 11.1.2.2
SQL authorization ID=DB2INST1
The Local database alias=HRDB

Db2=& gt;
The update score set score. YW=89 from student where score. XH=student. XH and student. The XM='zhang SAN feng'
Db2=& gt; DB20000I The SQL command completed successfully.

  •  Tags:  
  • DB2
  • Related