Here's an example:
Two tables A, B, to make the Memo field value in B equal to the name value of the corresponding ID in table a
Table A:id,name
1 Kings
2 Li
3 sheets
Table B:id,clientname
1
2
3
(MS SQL Server) statement:UpdateBSetClientName = A.name fromA, b where a.id = b.ID
(ORALCE) Statement:update b set (ClientName) = (SELECT name from a WHERE b.id = a.id)
(MYSQL) statement: : update A, B set a1 = B1, A2 = B2, A3 =< Span style= "color: #000000; line-height:22px; " > B3 WHERE a.id = b.ID
Update Set from statement format
set When you need to correlate a table for querying, the entire update executes two scans of the associated table, apparently with a lower efficiency.
in this case, The workaround for Sybase and SQL Server is to use update ... set ... from ... WHERE ... Syntax, which is actually getting updated data from the source table.
In SQL, table joins (left joins, right joins, Inner joins, and so on) are often used in SELECT statements, in the case of SQL syntax, which can also be used for update and DELETE statements, using J in these statements Oin also often get a multiplier effect.
Update t_orderform SET t_orderform.sellerid =b.l_tuserid
from T_orderform A left JOIN t_productinfo B on B.l_id=a.productid
Used to synchronize data from two tables!
Syntax supported by both ORALCE and DB2:
update A set (A1, A2, A3) = (select B1, B2, B3 B where a.id = b.ID)
MS SQL Server does not support such a syntax, the corresponding wording is:
UPDATEASETA1= B1, A2 = B2, A3 = B3 from A left JOIN B on a.id c15>= b.id
Personal feeling of MS SQL ServerUpdateSyntax is more powerful. MS SQL Server notation:
update A set A1 = B1, A2 Span style= "color: #808080; line-height:22px; " >= B2, A3 = B3 from A, B where a.id = b.id
The syntax for Oracle and DB2 is more cumbersome, as follows:
UPDATEASET(A1, A2, A3)=(SELECTB1, B2, B3 fromBWHERE a.id = b.ID)
where ID in (select b.id from B where a.id b.ID) BR style= "LINE-HEIGHT:22PX;" >
The syntax for MySQL is:
UPDATE A, B SET A1 = B1, A2 = B2, A3 = B3 WHERE a.id = b.id
CREATE TABLE cola_cell_point (name VARCHAR2, longitude number, latitude number, shape Mdsys. Sdo_geometry);
Update Cola_cell_point T1 set (t1.shape) = (select Mdsys.sdo_geometry (2001, Null,sdo_point_type (T2.longitude, T2.latitu DE, NULL), NULL, NULL) from Cola_cell_point T2 where T1.name=t2.name)
About the update set from where