728x90
๋ฐ์ํ
mysql ์ฌ๊ท์ฟผ๋ฆฌ(width recursive)
1. ๋ฐ๋ณต๋ถ์ด ์ฌ์ฉํ ๊ฒฝ์ฐ
2. union ํ์
3. ์ ํํ ๋ฐ์ดํฐ
with recursive number_sum AS (
select 1 as num // A
union all
select num + 1 as num // B
from number_sum
where num < 5
)
๋ฐฉ์์ A๊ฐ ํ๋ฒ ์คํ์ด ๋ฉ๋๋ค.
์ง๊ธ์ num ์ปฌ๋ผ๋ฐ์ดํฐ ํ๊ฐ์ ๋ฐ์ดํฐ๋ฐ์ ์์ผ๋ฏ๋ก ํ๋ฒ๋ง ์คํ๋ฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ ๊ฐ์์ ํจ์ B๊ฐ ์คํ๋ฉ๋๋ค.
์ซ์๋ ๊ณ์ ์ฆ๊ฐํ์ฌ num์ปฌ๋ผ์ ๋ฐ์ดํฐ๊ฐ 5 ๋ฏธ๋ง์ผ ๊ฒฝ์ฐ ์ฌ๊ท์ฟผ๋ฆฌ๋ ์ข
๋ฃ๋ฉ๋๋ค.
728x90
๋ฐ์ํ
LIST
'IT > Mysql' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Mysql Illegal mix of collations (utf8mb4_0900_ai_ci,IMPLICIT) and (utf8mb4_general_ci,IMPLICIT) for operation '=' (0) | 2023.07.31 |
---|---|
mysql insert ๋ค์ค (0) | 2022.11.03 |
mysql insert update ์ฟผ๋ฆฌ (0) | 2022.11.02 |
mysql update join ์ฟผ๋ฆฌ (0) | 2022.10.31 |