【发布时间】:2019-02-25 15:43:00
【问题描述】:
我需要在 Oracle 中编写脚本以在查询中按 / 字符拆分字符串“BP/593/00294”和“NC//12345”,以便在不同的列中包含值。
我在想这样的事情:
select regexp_substr(mystr, '[^/]+') as col1,
regexp_substr(c.usertext21,'[^/]+',1,2) as col2
from mytable
但在 col2 中,我从第二个字符串中丢失了空字符串值。 我需要保留两个字符串中的每个值。结果应该是这样的:
<table>
<th>col1</th>
<th>col2</th>
<th>col3</th>
<tr>
<td>BP</td>
<td>593</td>
<td>00294</td>
</tr>
<tr>
<td>NC</td>
<td></td>
<td>12345</td>
</tr>
</table>
任何帮助将不胜感激。 谢谢
【问题讨论】: