Programming/SQL
공백으로 해당 문자열 잘라서 갖고 오기
왕계란
2007. 7. 27. 10:48
select substring_index(fieldName,' ',n) from tableName;
A라는 테이블, address라는 필드에 '서울시 관악구 봉천4동 어쩌고 저쩌고'라는 주소가 있다.
이럴 경우 공백으로 문자열 2개까지 잘라서 보여줄 경우
select substring_index(address, ' ', 2) from A;
이렇게 하면 서울시 관악구까지만 출력이 된다.