써먹는 웹개발

[Mysql] 0 ~ 999까지 더미 테이블 생성하는방법 본문

웹개발/Database

[Mysql] 0 ~ 999까지 더미 테이블 생성하는방법

kmhan 2018. 7. 4. 15:17


728x90
반응형

SELECT

    SEQ.SeqValue

FROM

(

SELECT

    (HUNDREDS.SeqValue + TENS.SeqValue + ONES.SeqValue) SeqValue

FROM

    (

    SELECT 0  SeqValue

    UNION ALL

    SELECT 1 SeqValue

    UNION ALL

    SELECT 2 SeqValue

    UNION ALL

    SELECT 3 SeqValue

    UNION ALL

    SELECT 4 SeqValue

    UNION ALL

    SELECT 5 SeqValue

    UNION ALL

    SELECT 6 SeqValue

    UNION ALL

    SELECT 7 SeqValue

    UNION ALL

    SELECT 8 SeqValue

    UNION ALL

    SELECT 9 SeqValue

    ) ONES

CROSS JOIN

    (

    SELECT 0 SeqValue

    UNION ALL

    SELECT 10 SeqValue

    UNION ALL

    SELECT 20 SeqValue

    UNION ALL

    SELECT 30 SeqValue

    UNION ALL

    SELECT 40 SeqValue

    UNION ALL

    SELECT 50 SeqValue

    UNION ALL

    SELECT 60 SeqValue

    UNION ALL

    SELECT 70 SeqValue

    UNION ALL

    SELECT 80 SeqValue

    UNION ALL

    SELECT 90 SeqValue

    ) TENS

CROSS JOIN

    (

    SELECT 0 SeqValue

    UNION ALL

    SELECT 100 SeqValue

    UNION ALL

    SELECT 200 SeqValue

    UNION ALL

    SELECT 300 SeqValue

    UNION ALL

    SELECT 400 SeqValue

    UNION ALL

    SELECT 500 SeqValue

    UNION ALL

    SELECT 600 SeqValue

    UNION ALL

    SELECT 700 SeqValue

    UNION ALL

    SELECT 800 SeqValue

    UNION ALL

    SELECT 900 SeqValue

    ) HUNDREDS

) SEQ


출처 : https://code.i-harness.com/ko/q/2d984

728x90
반응형


Comments