要在SELECT上用逗号替换点,可以使用REPLACE()
。
以下是语法-
select replace(yourColumnName, '.' , ',' ) from yourTableName;
让我们首先创建一个表-
mysql> create table DemoTable ( Value float );
使用插入命令在表中插入记录-
mysql> insert into DemoTable values(4.56); mysql> insert into DemoTable values(456.23); mysql> insert into DemoTable values(1078.3); mysql> insert into DemoTable values(2000.50); mysql> insert into DemoTable values(78.99);
使用选择命令显示表中的记录-
mysql> select *from DemoTable;
这将产生以下输出-
+--------+ | Value | +--------+ | 4.56 | | 456.23 | | 1078.3 | | 2000.5 | | 78.99 | +--------+ 5 rows in set (0.00 sec)
以下是在SELECT上用逗号替换点的查询-
mysql> select replace(Value,'.',',') from DemoTable;
这将产生以下输出-
+------------------------+ | replace(Value,'.',',') | +------------------------+ | 4,56 | | 456,23 | | 1078,3 | | 2000,5 | | 78,99 | +------------------------+ 5 rows in set (0.07 sec)