Implicit cast:
{code}
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES ('1.5'),('1e2');
SELECT * FROM t1;
{code}
returns:
{noformat}
+------+
| a |
+------+
| 2 |
| 100 |
+------+
{noformat}
I.e. it understands floating point formats.
Explicit CAST works differently:
{code}
SELECT CAST('1.5' AS SIGNED), CAST('1e2' AS SIGNED);
SHOW WARNINGS;
{code}
returns:
{noformat}
+-----------------------+-----------------------+
| CAST('1.5' AS SIGNED) | CAST('1e2' AS SIGNED) |
+-----------------------+-----------------------+
| 1 | 1 |
+-----------------------+-----------------------+
1 row in set, 2 warnings (0.00 sec)
+---------+------+------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '1.5' |
| Warning | 1292 | Truncated incorrect INTEGER value: '1e2' |
+---------+------+------------------------------------------+
{noformat}
i.e. it does not understand the floating point formats.
Explicit CAST should be fixed to understand the floating point format.
Implicit cast:
{code}
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES ('1.5'),('1e2');
SELECT * FROM t1;
{code}
returns:
{noformat}
+------+
| a |
+------+
| 2 |
| 100 |
+------+
{noformat}
I.e. it understands floating point formats.
Explicit CAST works differently:
{code}
SELECT CAST('1.5' AS SIGNED), CAST('1e2' AS SIGNED);
SHOW WARNINGS;
{code}
returns:
{noformat}
+-----------------------+-----------------------+
| CAST('1.5' AS SIGNED) | CAST('1e2' AS SIGNED) |
+-----------------------+-----------------------+
| 1 | 1 |
+-----------------------+-----------------------+
1 row in set, 2 warnings (0.00 sec)
+---------+------+------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '1.5' |
| Warning | 1292 | Truncated incorrect INTEGER value: '1e2' |
+---------+------+------------------------------------------+
{noformat}
i.e. it does not understand floating point formats.
Explicit CAST should be fixed to understand the floating point format.
Implicit cast:
{code}
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES ('1.5'),('1e2');
SELECT * FROM t1;
{code}
returns:
{noformat}
+------+
| a |
+------+
| 2 |
| 100 |
+------+
{noformat}
I.e. it understands floating point formats.
Explicit CAST works differently:
{code}
SELECT CAST('1.5' AS SIGNED), CAST('1e2' AS SIGNED);
SHOW WARNINGS;
{code}
returns:
{noformat}
+-----------------------+-----------------------+
| CAST('1.5' AS SIGNED) | CAST('1e2' AS SIGNED) |
+-----------------------+-----------------------+
| 1 | 1 |
+-----------------------+-----------------------+
1 row in set, 2 warnings (0.00 sec)
+---------+------+------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '1.5' |
| Warning | 1292 | Truncated incorrect INTEGER value: '1e2' |
+---------+------+------------------------------------------+
{noformat}
i.e. it does not understand floating point formats.
Explicit CAST should be fixed to understand the floating point format.
Implicit cast:
{code}
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES ('1.5'),('1e2');
SELECT * FROM t1;
{code}
returns:
{noformat}
+------+
| a |
+------+
| 2 |
| 100 |
+------+
{noformat}
I.e. it understands floating point formats.
Explicit CAST works differently:
{code}
SELECT CAST('1.5' AS SIGNED), CAST('1e2' AS SIGNED);
SHOW WARNINGS;
{code}
returns:
{noformat}
+-----------------------+-----------------------+
| CAST('1.5' AS SIGNED) | CAST('1e2' AS SIGNED) |
+-----------------------+-----------------------+
| 1 | 1 |
+-----------------------+-----------------------+
1 row in set, 2 warnings (0.00 sec)
+---------+------+------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: '1.5' |
| Warning | 1292 | Truncated incorrect INTEGER value: '1e2' |
+---------+------+------------------------------------------+
{noformat}
i.e. it does not understand floating point formats.
Explicit CAST should be fixed to understand floating point format.