how to convert varchar to float in mysql



Instructions

    • 1

      Go to a MySQL prompt so that commands can be entered by typing the following:

      mysql>

      From here, varchar values can be converted into floating point numbers.

    • 2

      Type in a select statement, formatting the varchar as a floating point number by placing "0.0" after the varchar string to be converted. For example:

      sql> Select '1.5'+0.0;

      This is displayed as 1.5 in MySQL as expected.

    • 3

      Enter a large floating point number as a float, and consider how the floating point number is rounded off, as in the following example:

      mysql> SELECT '18215376320333968'+0.0;

      The result of this is the number below (due to rounding):

      1.8215376320334e+16

    • 4

      Include letters in the floating point number to be converted as follows:

      Select 'abcdef1234'+5.5 ;

      This results in an output of "5.5" as the letters are ignored.



Read more: http://www.ehow.com/how_8539227_convert-varchar-float-mysql.html#ixzz328azNy00


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值