orcale 中instr的应用(截串)

解决问题的代码实现:
select ci_id,(select wm_concat(stu_name) from pm_stu where instr(stu_ids,stu_id)>0) stu_names
from pm_ci

表:
create table pm_ci
(ci_id varchar(20) primary key,
stu_ids varchar(100));

insert into pm_ci values(‘1’,’1,2,3,4’);
insert into pm_ci values(‘2’,’1,4’);
表2:
create table pm_stu
(stu_id varchar(20) primary key,
stu_name varchar(20));
insert into pm_stu values(‘1’,’张三’);
insert into pm_stu values(‘2’,’李四’);
insert into pm_stu values(‘3’,’王五’);
insert into pm_stu values(‘4’,’赵六’);
问题如下:
orcale 中instr的应用(截串)_第1张图片
实现如下:
orcale 中instr的应用(截串)_第2张图片

你可能感兴趣的:(web开发,orcale)