MySQL查询将列除以100?
让我们首先创建一个表-
mysql> create table DemoTable ( Number float );
使用插入命令在表中插入记录-
mysql> insert into DemoTable values(1000); mysql> insert into DemoTable values(1); mysql> insert into DemoTable values(10); mysql> insert into DemoTable values(100); mysql> insert into DemoTable values(390);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
+--------+ | Number | +--------+ | 1000 | | 1 | | 10 | | 100 | | 390 | +--------+ 5 rows in set (0.00 sec)
以下是将列除以100-的查询
mysql> update DemoTable set Number=Number/100; Rows matched: 5 Changed: 5 Warnings: 0
让我们再次显示表记录-
mysql> select * from DemoTable;
这将产生以下输出-
+--------+ | Number | +--------+ | 10 | | 0.01 | | 0.1 | | 1 | | 3.9 | +--------+ 5 rows in set (0.00 sec)