【问题标题】:Populate MySQL table with dummy data using times from another table使用另一个表中的时间用虚拟数据填充 MySQL 表
【发布时间】:2014-09-23 06:15:51
【问题描述】:

我有一个用时间戳填充的表,在创建另一个表时,我想为每个时间戳填充零值。例如:

Timestamps table
Timestamps |
-----------|
2014-07-01 |
2014-07-02 |
2014-07-03 |
2014-07-04 |
2014-07-05 |
2014-07-06 |

我想像这样创建第二个表:

Table 2
Timestamps | Values
-----------|--------
2014-07-01 | 0
2014-07-02 | 0
2014-07-03 | 0
2014-07-04 | 0
2014-07-05 | 0
2014-07-06 | 0

有没有简单的方法可以做到这一点?

【问题讨论】:

    标签: mysql populate


    【解决方案1】:
    create table new_table as
    select t.*, 0 as values
    from your_table t;
    

    就这么简单。

    【讨论】:

      猜你喜欢
      • 2011-06-13
      • 1970-01-01
      • 2023-03-21
      • 2013-02-23
      • 2013-08-30
      • 1970-01-01
      • 2021-08-24
      • 2016-05-28
      • 1970-01-01
      相关资源
      最近更新 更多