Cara Update Join di MS SQL Server & MySQL

Query Update Join bermanfaat untuk mengupdate nilai table A dengan nilai table B berdasarkan relasi antara tabel A dan B. Ya pokoknya gitu deh. wink

Update Join di Microsoft SQL Server

UPDATE t1
SET t1.c1 = t2.c2, t2.c2 = expression, ...
FROM t1 [INNER | LEFT] JOIN t2 ON join_predicate
WHERE where_condition;

Update Join di MySQL

UPDATE T1 [INNER JOIN | LEFT JOIN] T1 ON T1.C1 = T2. C1
SET T1.C2 = T2.C2, T2.C3 = expr
WHERE where_condition

Syntax update join antara ms sql server dan mysql hampir sama, cuma beda urutan SET-nya saja. Pada ms sql server SET ditulis sebelum JOIN, sedang pada MySQL JOIN dulu baru SET.

Tetap Sehat, Tetap Semangat, agar dapat Tetap dalam Perdjoeangan!!

Referensi:

  • http://www.mysqltutorial.org/mysql-update-join/
  • http://www.sqlservertutorial.net/sql-server-basics/sql-server-update-join/

Hartadi

I'm a Passionate Programmer ;)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.