IT민들레 - M365 Specialist

user-agent 에 따른 browser 명 업데이트 SQL 본문

IT, Digital, 컴퓨터, 스마트폰

user-agent 에 따른 browser 명 업데이트 SQL

IT민들레 2016. 2. 18. 14:33
728x90
반응형

브라우저 agent명으로 browser 이름을 지정하기 위한 SQL문을 작성해 보았습니다. 노가다성이지만 적절히 활용해 보세요.

 

특히 Windows10 + IE11 환경에서는 trident/8.x 로 지정해준 MS의 특이한 발상을 볼 수 있답니다.

 

/*
 IE 브라우저 버전정보 업데이트 160217
*/
update 테이블명
set browser = (
 case
  when INSTR(LOWER(user_agent),'trident/') > 0
   then
    case
     when INSTR(LOWER(user_agent),'trident/8.') > 0 then 'Internet Explorer 11' --Windows 10 + IE11
     when INSTR(LOWER(user_agent),'trident/7.') > 0 then 'Internet Explorer 11'
     when INSTR(LOWER(user_agent),'trident/6.') > 0 then 'Internet Explorer 10'
     when INSTR(LOWER(user_agent),'trident/5.') > 0 then 'Internet Explorer 9'
     when INSTR(LOWER(user_agent),'trident/4.') > 0 then 'Internet Explorer 8'
     else 'This browser have not Trident words'
    end
  else
   case
    when INSTR(LOWER(user_agent),'msie 11') > 0 then 'Internet Explorer 11'
    when INSTR(LOWER(user_agent),'msie 10') > 0 then 'Internet Explorer 10'
    when INSTR(LOWER(user_agent),'msie 9') > 0 then 'Internet Explorer 9'
    when INSTR(LOWER(user_agent),'msie 8') > 0 then 'Internet Explorer 8'
    when INSTR(LOWER(user_agent),'msie 7') > 0 then 'Internet Explorer 7'
    when INSTR(LOWER(user_agent),'msie 6') > 0 then 'Internet Explorer 6'
    else 'This browser have not MSIE words'
   end
  end
)

728x90
반응형