SQL Multi-Table Federated update

Source: Internet
Author: User
Tags sql server example sqlite access database

1. SQLite Multi-Table Update method

UPDATE TA SET col1=tb.col1from tableA ta INNER JOIN tableB TB on Ta.col2=tb.col2

This is a very simple batch update statement in SQL Server that supports this syntax but is not supported in SQLite, which can be converted to the following syntax:

UPDATE TableA SET col1= (SELECT col1 from TableB WHERE col2=tablea.col2)

2. SQL Server Multi-table Update method

UPDATE {table_name with (< table_hint_limited > [... n]) | view_name | rowset_function_limited} SET {Column_na me = {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:

UPDATE TA SET ta.col1=tb.col1,ta.col2=tb.col2 from TableA ta,tableb TB WHERE ta.col3=tb.col3

3. Access database Multi-table Update method
x = "Update" + DLTB + "A INNER join TBAREA2 B on A.objectid=b.fid set a." + FD_DLTB_XZDWMJ + "=B.AREA_XZDW, A." + Fd_d LTB_LXDWMJ + "=B.AREA_LXDW";
Sqllist.add (x);

4. Oracle Multi-Table Update method
Oracle Syntax:
UPDATE updatedtable
SET (Col_name1[,col_name2 ...]) = (SELECT col_name1,[,col_name2 ...] From srctable
[WHERE Where_definition])

Oracel Example:
UPDATE Landleveldata A set (A.gqdltks, A.bztks) = (select B.gqdltks,
B.bztks from GDQLPJ b where A.GEO_CODE=B.LXQDM)

5. MySQL Multi-Table Update method
MySQL Syntax:
UPDATE table_references SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE Where_definition]


MySQL Example:
UPDATE Landleveldata A, GDQLPJ b
SET a.gqdltks= B.gqdltks, A.bztks=b.bztks
WHERE A.GEO_CODE=B.LXQDM

SQL Multi-Table Federated update

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.