/**
http://forums.mysql.com/read.php?98,54553,54561
**/
You can use the CAST function. Here is some code to show you an example and the difference it makes in the results returned:
mysql> SELECT CAST('19.45' AS DECIMAL(5,2)) as result;
+--------+
| result |
+--------+
| 19.45 |
+--------+
1 row in set (0.04 sec)
mysql> SELECT '19.45' - 19.45;
+-----------------+
| '19.45' - 19.45 |
+-----------------+
| 0 |
+-----------------+
1 row in set (0.00 sec)
mysql> SELECT CAST('19.45' AS DECIMAL(5,2)) - 19.45;
+---------------------------------------+
| CAST('19.45' AS DECIMAL(5,2)) - 19.45 |
+---------------------------------------+
| 0.00 |
+---------------------------------------+
1 row in set (0.00 sec)
Jay Pipes
Community Relations Manager, North America, MySQL Inc.
Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com
mysql convert()
最新推荐文章于 2022-07-27 14:55:35 发布