0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JOINして複数の関連テーブルの条件で絞り込んだ結果をUPDATEするSQL

Posted at

題名の通り、複数の関連テーブルの条件で絞り込んだものだけをUPDATEしたいときのSQLの書き方メモ。

UPDATE tableA
  LEFT OUTER JOIN tableB
    ON tableA.tableB_id = tableB.id
  LEFT OUTER JOIN tableC
    ON tableB.tableC_id = tableC.id
SET column_name_to_update = NULL
WHERE tableC.select_column_name = select_val ;

(まだ本当に正しいか検証していない…)

SETWHERE の順序に注意。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?