gpt4 book ai didi

mysql - 如何在mysql中复制行

转载 作者:行者123 更新时间:2023-11-30 22:15:58 26 4
gpt4 key购买 nike

我有一个包含以下数据的表

Region Market    Cluster   Dt-Accept Count
South Karnataka Bangalore 23-05-2015 5
North Delhi NewDelhi 25-08-2015 3

我想要一个 sql 语句,它应该根据存储在计数中的数字重复行数。

Region Market    cluster   Dt-Accept  count
South Karnataka Bangalore 23-05-2015 5
South Karnataka Bangalore 23-05-2015 5
South Karnataka Bangalore 23-05-2015 5
South Karnataka Bangalore 23-05-2015 5
South Karnataka Bangalore 23-05-2015 5
North Delhi NewDelhi 25-08-2015 3
North Delhi NewDelhi 25-08-2015 3
North Delhi NewDelhi 25-08-2015 3

我怎样才能做到这一点?

最佳答案

试试这个

    SELECT Region,Market,cluster,Dt-Accept,count
FROM Table1 T JOIN (
SELECT 0 No UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL
SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL
SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL
SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL
SELECT 12 UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL
SELECT 15
) S ON T.count > S.No

Fiddle Demo

关于mysql - 如何在mysql中复制行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38268994/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com