比如:
原表(表名:table1)
| id | num |
|---|---|
| 1 | 001,002,003 |
| 2 | 001,002 |
转换成
| id | num |
|---|---|
| 1 | 001 |
| 1 | 002 |
| 1 | 003 |
| 2 | 001 |
| 2 | 002 |
使用lateral view explode()语法
使用方法是:
1
2
3
4
select id,num_per
from table1
lateral view explode(split(num, ',')) tmpTable as num_per
where xx=xx
注意:
比如:
原表(表名:table1)
| id | num |
|---|---|
| 1 | 001,002,003 |
| 2 | 001,002 |
转换成
| id | num |
|---|---|
| 1 | 001 |
| 1 | 002 |
| 1 | 003 |
| 2 | 001 |
| 2 | 002 |
使用lateral view explode()语法
使用方法是:
1
2
3
4
select id,num_per
from table1
lateral view explode(split(num, ',')) tmpTable as num_per
where xx=xx
注意: