개발정보

MYSQL 유효한 정보, MYSQL에서 ROWNUM 구현하기, MySql DATE 관련 변환 함수 사용

쿠카곰돌이 2019. 6. 22. 12:23
반응형

MYSQL에서 ROWNUM 구현하기

 

SELECT @RNUM := @RNUM + 1 AS ROWNUM, t.*
FROM

  (

    SELECT *

    FROM TB_TABLE_NAME

    ORDER BY TAB_COL_NAME

  ) t,

  ( SELECT @RNUM := 0 ) R

 

 

MySql DATE 관련 변환 함수 사용

SELECT TRNS_ID
    , CONCAT('SKKAA-Z200000001-',DATE_FORMAT(now(), '%Y%m%d%H%i%s')) as trns_data
    , DATE_FORMAT(now(), '%Y%m%d%H%i%s') as now_date
    , STR_TO_DATE(DATE_FORMAT('20130423094221', '%Y%m%d%H%i%s'),'%Y%m%d%H%i%s') as date_str
FROM DATA_TABLE

 

update tbb_cook_content
   set content_nm = substr(content_nm, INSTR(content_nm,'>')+1, length(content_nm))
 where `root_id` = 1
 
 
 
 select INSTR(content_nm,'>') as in_nm , LOCATE(content_nm,'>') as l_nm 
, substr(content_nm, INSTR(content_nm,'>')+1, length(content_nm)) as contnet_short
, content_nm  
 from tbb_cook_content

반응형