我有以下内容:
在 MYSQL 数据库中通过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 |
答案 0 :(得分:0)
在这种情况下,您可以输入硬编码值:
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;