gpt4 book ai didi

mysql - SELECT语句,值用逗号分隔

转载 作者:行者123 更新时间:2023-11-29 16:06:36 24 4
gpt4 key购买 nike

我有以下内容:

在MYSQL DB中通过sql查询可以做到这一点吗?还是在结果后需要php?
谢谢

name | date

test1 | 2019-01-01,2019-02-02,2019-03-03,2019-03-03

test2 | 2019-04-01,2019-05-01,2019-06-01,2019-07-01


并希望得到:

name | date | 

test1 | 2019-01-01 |
test1 | 2019-02-02 |
test1 | 2019-03-03 |
test1 | 2019-03-03 |
test2 | 2019-04-01 |
test2 | 2019-05-01 |
test2 | 2019-06-01 |
test2 | 2019-07-01 |

最佳答案

对于这种特殊情况,您可以输入硬编码值:

select m.* from(select name,substring(date,1,10) as str
from table1
union all
select name,substring(date,12,10) as str
from table1
union all
select name,substring(date,23,10) as str
from table1
union all
select name,substring(date,34,10) as str
from table1)m order by m.name;


https://www.db-fiddle.com/f/xcRVMVV5qeh7J2BK1zMP4E/0

关于mysql - SELECT语句,值用逗号分隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55687278/

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