By now, I understood there is no BOOLEAN
type in mysql and internally it converts to tinyint(1)
when the datatype is boolean. But I also came across that tinyint
is not being handled by CAST
or CONVERT
function.
So basically my question is is there any direct way to typecast the datatype to TINYINT(1) the way it can be handled for any other data like DATE.
Examples :
select cast(column_name as DATE) -- Works
select cast(column_name as tinyint) -- Doesn't work
So how can I simply convert the type to tinyint(1)
without altering the table ..
Did you read the documentation for CAST() and CONVERT() ?
Those functions don't support all data types. They will not cast or convert to TINYINT. The closest data type you can cast or convert to is an INTEGER (either SIGNED or UNSIGNED).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.