LoginSignup
19
19

More than 5 years have passed since last update.

MySQLでSELECTした結果をUPDATEしたい

Last updated at Posted at 2017-03-28

データ移行作業がありMySQLでSELECT UPDATE的なことができるかを調査したところ、
以下のSQLでできたので備忘録として残しておきます。

UPDATE
    tableA t1,
    tableB t2
SET 
    t1.column_01 = t2.column_01
WHERE
    t1.id = t2.id

t2の内容をt1に更新するSQLとなります。

今回の移行はdate → timestampの型変換もあったので、
一緒に残しておきます。

SET
    t1.timestamp = from_unixtime(t2.date) 
19
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
19