How to convert bool to int in MySql

I am new to MySql. Therefore, I do not know many things, such as Data Casting. How to convert bool to int in MySql. And also, how can I convert the decimal value to Int in MySql.

+6
source share
2 answers

Pointing the boolean type to integer:

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

The same goes for decimal numbers and strings:

 SELECT CAST("1.23" AS SIGNED INTEGER); /* 1 */ 
+7
source

Source: https://habr.com/ru/post/889921/


All Articles