Differences in UPDATE statements in different databases

xiaoxiao2021-03-06  43

The grammar supported by Oralce and DB2:

Update

A

Set

(A1, A2, A3)

=

(

SELECT

B1, B2, B3

From

B

WHERE

A.ID

=

B.ID)

MS SQL Server does not support such syntax, corresponding ways are:

Update

A

Set

A1

=

B1, A2

=

B2, A3

=

B3

From

A

Left

Join

B

On

A.ID

=

B.ID

Personally feel more powerful in MS SQL Server's UPDATE. MS SQL Server Writing:

Update

A

Set

A1

=

B1, A2

=

B2, A3 = B3

From

A, B

WHERE

A.ID

=

B.ID

The writing in Oracle and DB2 is more troublesome, as follows:

Update

A

Set

(A1, A2, A3)

=

(

SELECT

B1, B2, B3

From

B

WHERE

A.ID

=

B.ID)

WHERE

Id

In

(

SELECT

B.ID

From

B

WHERE

A.ID

=

B.ID)

转载请注明原文地址:https://www.9cbs.com/read-55440.html

New Post(0)