How can I convert a string to a float in mysql?

前端 未结 3 1623
日久生厌
日久生厌 2020-12-03 02:25

I have a table containing latitude and longitude values stored as strings (VARCHAR) which I\'d like to convert to FLOAT (10,6).

However the

3条回答
  •  抹茶落季
    2020-12-03 03:11

    This will convert to a numeric value without the need to cast or specify length or digits:

    STRING_COL+0.0

    If your column is an INT, can leave off the .0 to avoid decimals:

    STRING_COL+0

提交回复
热议问题