Combine two MYSQL table with same column Name

后端 未结 4 1202
猫巷女王i
猫巷女王i 2021-02-10 23:14

I have two table

table one is scheduletime

id    |   edition    | time   | 
1     |       1      | 9:23am |
2     |       2      | 10:23am|

4条回答
  •  佛祖请我去吃肉
    2021-02-10 23:19

    Try this:

    SELECT 
        'Scheduleed' AS Caption, 
        Edition, 
        time 
    FROM scheduletime
    UNION ALL
    SELECT 
        'actual' AS Caption, 
        Edition, 
        time 
    FROM actualtime
    ORDER BY Edition, Caption DESC
    

    OUTPUT:

    |    CAPTION | EDITION |    TIME |
    ----------------------------------
    | Scheduleed |       1 |  9:23am |
    |     actual |       1 | 10:23am |
    | Scheduleed |       2 | 10:23am |
    |     actual |       2 | 11:23am |
    

    See this SQLFiddle

提交回复
热议问题