Create table tempdb.dbo.test
(code varchar(12) null
,scan varchar(12) null
)
go
insert into tempdb.dbo.test values('a', '1;2;3;')
insert into tempdb.dbo.test values('b', '10;11;')
insert into tempdb.dbo.test values('c', '15;')
insert into tempdb.dbo.test values('d', '20;21;22;')
select * from tempdb.dbo.test
select * from tempdb.dbo.test where CHARINDEX('2',scan) > 0
--결과--
code scan
a 1;2;3;
d 20;21;22;
-원하는결과물
code scan
a 1;2;3;
--결과값을 a 에 해당하는 필드만 조회 할려고 합니다.
code 필드는 예시를 위한 필드이며 실제는 where 조건에서 사용할수 없습니다.
scan 필드로만 조회해야만 합니다.
숫자와 숫자 구분자는 ; 입니다.
시행착오 거듭하다..질문드립니다.. 어떻게 쿼리문을 작성해야 할지 고민입니다.
감사합니다.
즐거운 명절 보내세요.