遍历一个字符,并将其中的每个字符都作为一行返回,但是SQL没有循环操作。例如,要将表EMP中的ENAME值为“KING”的字符串显示为4行,每行都包含“KING”中的一个字符。
create table t10 (id int);
insert into t10 values(1);
insert into t10 values(2);
insert into t10 values(3);
insert into t10 values(4);
insert into t10 values(5);
insert into t10 values(6);
insert into t10 values(7);
insert into t10 values(8);
insert into t10 values(9);
insert into t10 values(10);
select substr(e.ename,iter.pos,1) as C
from (select ename from emp where ename='KING') e,
(select id as pos from t10) iter
where iter.pos<=length(e.ename);