遍历一个字符,并将其中的每个字符都作为一行返回,但是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);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2021-07-10
  • 2022-12-23
  • 2022-02-20
  • 2021-06-13
猜你喜欢
  • 2022-12-23
  • 2021-05-11
  • 2021-06-16
  • 2021-05-17
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案