Let us first create a table:
mysql> create table DemoTable731 (Value varchar(100)); Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command -
mysql> insert into DemoTable731 values('4.50'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable731 values('7.83'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable731 values('8.91'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable731 values('560.34'); Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement -
mysql> select *from DemoTable731;
This will produce the following output -
+--------+ | Value | +--------+ | 4.50 | | 7.83 | | 8.91 | | 560.34 | +--------+ 4 rows in set (0.00 sec)
Here is the query to convert string to double -
mysql> select Value+0.0 AS demo from DemoTable731;
This will produce the following output -
+-----------+ | demo | +-----------+ | 4.5 | | 7.83 | | 8.91 | | 560.34 | +-----------+ 4 rows in set (0.28 sec)