MySQL/MariaDB updae join... ๐
mysql์์ ํ ์ด๋ธ์ ์กฐ์ธํด์ update๋ฅผ ์คํํด์ผ ๋๋ ๊ฒฝ์ฐ ์๋์ฒ๋ผ ์กฐ์ธํด์ ์ ๋ฐ์ดํธ๋ฅผ ํ๋ฉด ๋๋ค.
์์ฃผ ์ฐ์ผ ๋ฏ ํ๋ ๋ฉ๋ชจ ํด๋
-- mainTable๊ณผ subTable์ no๋ก ์กฐ์ธํ ๋ค no๊ฐ ๊ฐ์ ๋ฐ์ดํฐ๋ง use_yn๊ฐ์ 'Y'๋ก ๋ณ๊ฒฝ
-- (์์ชฝ ๋ชจ๋ ์๋ ๋ฐ์ดํฐ๋ง ๊ฐ์ ธ์ค๊ธฐ ์ํด inner join ์ฌ์ฉ)
update mainTable a inner join subTable b on a.no = b.no
set a.use_yn = 'Y'
where a.no = b.no
;

'IT > DataBase' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Oracle]ORACLE ๊ณ์ธตํ ์ฟผ๋ฆฌ (0) | 2022.11.29 |
---|---|
[Oracle]ORACLE 12C SQL์ ์ถ๊ฐ๋ ์๋ก์ด ๊ธฐ๋ฅ (0) | 2022.11.29 |
[Oracle] Oracle ์ํ์ค ์์ฑ ์ฟผ๋ฆฌ (0) | 2022.11.29 |
[Oracle] Oracle SELECTํ ๊ฐ์ผ๋ก UPDATEํ๊ธฐ (0) | 2022.11.29 |
[Oracle] Oracle ํน์ ์๋ฆฟ์๋ง ์ ๋ฐ์ดํธ(feat. update + substr) (0) | 2022.11.29 |
๋๊ธ