Is there a SQL function to expand table?

后端 未结 4 704
面向向阳花
面向向阳花 2021-01-24 21:48

I vaguely remember there being a function that does this, but I think I may be going crazy.

Say I have a datatable, call it table1. It has three columns: column

4条回答
  •  情话喂你
    2021-01-24 22:24

    if you want a cartesian product (all the combination on a row ) you could use

    SELECT a.*, b.*, c.* 
    FROM table1 a
    CROSS JOIN table1 b
    CROSS JOIN table1 c
    

    if you want the same rows repeated you can use UNION ALL

    SELECT *
    FROM table1 
    UNION ALL 
    SELECT *
    FROM table1 
    UNION ALL 
    SELECT *
    FROM table1 
    

提交回复
热议问题