开发者

How to convert bool to int in MySql

开发者 https://www.devze.com 2023-03-11 17:37 出处:网络
I\'m new to MySql. So I don\'t know many things like Casting of data types.开发者_如何学JAVAHow can I convert bool to int in MySql. And also how can I convert decimal to Int in MySql.Typecasting boole

I'm new to MySql. So I don't know many things like Casting of data types. 开发者_如何学JAVAHow can I convert bool to int in MySql. And also how can I convert decimal to Int in MySql.


Typecasting boolean to integer:

SELECT CAST(1=1 AS SIGNED INTEGER); /* 1 */

Same for decimal and strings:

SELECT CAST("1.23" AS SIGNED INTEGER); /* 1 */
0

精彩评论

暂无评论...
验证码 换一张
取 消