Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Update to realize multi-table joint update in SQL

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to use Update to achieve multi-table joint update in SQL, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

(1) sqlite multi-table update method

The copy code is as follows:

/ /--

Update t1 set col1=t2.col1

From table1 t1

Inner join table2 t2 on t1.col2=t2.col2

This is a very simple batch update statement that supports this syntax in SqlServer but not in sqlite

Sqlite can be converted to the following syntax

The copy code is as follows:

Update table1 set col1= (select col1 from table2 where col2=table1.col2)

Update ta_jbnt_tzhd_pht_Area_xiang set T1 = (select sys_xzqhdm.name from sys_xzqhdm

Where t2=sys_xzqhdm.code)

(2) SQL Server multi-table update method

The copy code is as follows:

/ /--

SQL Server syntax: UPDATE {table_name WITH (

< table_hint_limited >

[. N]) |

View_name | rowset_function_limited} SET {column_name = {expression | DEFAULT

| | NULL} | @ variable = expression | @ variable = column = expression} [,... n] |

{{[FROM {

< table_source >

} [,... n]] [WHERE

< search_condition >

]} | [

WHERE CURRENT OF {{[GLOBAL] cursor_name} | cursor_variable_name}]} [

OPTION (

< query_hint >

[,. N])]

SQL Server example:

The copy code is as follows:

Update a set a.gqdltkscompilb.gqdltksMagnetica.bztkscompilb.bztks from

Landleveldata a,gdqlpj b where a.GEO_Code=b.lxqdm

Update method of multiple tables in access Database

The copy code is as follows:

X = "update" + DLTB + "an inner join tbarea2 b on a.objectid=b.FID set a." + fd_dltb_xzdwmj + "= b.area_xzdw, a." + fd_dltb_lxdwmj + "= b.area_lxdw"

SQLList.Add (x)

(3) Oracle multi-table update method

Oracle syntax:

The copy code is as follows:

UPDATE updatedtable SET (col_name1 [, col_name2...]) = (SELECT

Col_name1, [, col_name2...] FROM srctable [WHERE where_definition])

Oracel example:

The copy code is as follows:

Update landleveldata a set (a.gqdltks, a.bztks) = (select b.gqdltks

B.bztks from gdqlpj b where a.GEO_Code=b.lxqdm)

(4) MySQL multi-table update method

MySQL syntax:

The copy code is as follows:

UPDATE table_references SET col_name1=expr1 [, col_name2=expr2...]

[WHERE where_definition]

MySQL example:

The copy code is as follows:

Update landleveldata a, gdqlpj b set a.gqdltks = b.gqdltks, a.bztks=

B.bztks where a.GEO_Code=b.lxqdm

On how to use Update in SQL to achieve multi-table joint update is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report