Mysql 특정 구분자로 글자나누기

필드의 값이 "aa||bb||cc" 일때 || 단위로 문자를 나누고 싶다면

select substring_index(필드,'||', 1) from 테이블 where substring_index(필드,'||', 1)
-> aa

select substring_index(필드,'||', 2) from 테이블 where substring_index(필드,'||', 2)
-> bb

select substring_index(필드,'||', 3) from 테이블 where substring_index(필드,'||', 3)
-> cc

위와같은 예제를 이용하여 문자를 나눌 수 있다.

댓글 없음:

Powered by Blogger.