개발공부

[SQL] 타입 변환 CAST

dfgdfgfdg 2021. 1. 4. 02:42

www.mysqltutorial.org/mysql-cast/

 

MySQL CAST() Function

This tutorial shows you how to use MySQL CAST function to convert a value of any type into a value with a specified type.

www.mysqltutorial.org

 

cast type의 종류

binary

char

signed

date

datetime

time

unsigned

 

예시)

문자를 숫자로 변환
select cast('1' as unsigned) as num
숫자를 문자로 변환
select cast(2 as char(1)) as str