Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- partitioning
- node.js
- Lag
- ServerSentEvent
- SSE
- 실시간알림
- 파티셔닝
- 개발자
- Node.js기본
- EventSource
- frontend
- localStorage
- Partition
- 열공하자
- 성장기
- mariadb
- node.js란
- PostgreSQL
Archives
- Today
- Total
써치킴의 우당탕탕 개발 블로그
[문자열 관련 함수] Position 본문
Position 함수
특정 부분 문자열이 ‘처음으로 등장하는 위치’를 반환하는 함수
NUMBER 타입으로 값을 반환
기본구조
POSITION(substring in string)
- substring: 찾으려는 문자열을 의미
- string: 전체 문자열을 의미
예시
SELECT POSITION('llo' IN 'Hello, world!'); -- 결과 : 3
-- 실무에선 position 함수를 이용해 특정 문자를 찾고,
-- 특정 컬럼에서 substring 함수를 이용해 특정 문자 다음 문자열부터 표출하게 잘라주었다.
select substring(특정컬럼, position('>' in 특정컬럼) + 1) as "nm"
from t_test
-- , 로 이어진 값에서 특정 문자가 있으면 Y 아니면 N으로 반환하여 조회하는 데에 사용하였다.
select case when position('^^ ' in test_nm) > 0 then 'Y' else 'N' end as hp_yn
, case when position('>< ' in test_nm) > 0 then 'Y' else 'N' end as sh_yn
, case when position(':) ' in test_nm) > 0 then 'Y' else 'N' end as sm_yn
from t_test
'PostgreSQL' 카테고리의 다른 글
[그룹 내 행 순서 함수] LAG (0) | 2024.06.25 |
---|---|
[그룹 내 행 순서 함수] LEAD (0) | 2024.06.19 |
[날짜/시간 관련] date_trunc 함수 (0) | 2024.06.18 |
Comments