wilson's story

문자열 잘라서 가져오기 본문

DB/mysql

문자열 잘라서 가져오기

wilson 2008. 5. 23. 17:51
반응형
--mysql

SELECT 
      IF(LENGTH(content) > 50, 
     CONCAT(SUBSTRING(content, 1, 50), '....'), 
     content) 
     content,
    FROM test_table
   order by id DESC 

--content 라는 컬럼에서 50보다 길면 뒤에 '...' 을 붙여서 출력


반응형