要删除部分数据,请与一起使用UPDATE命令REPLACE()。让我们首先创建一个表-mysql> create table DemoTable1583
-> (
-> GameDetails text
-> );
使用插入命令在表中插入一些记录-mysql> insert into DemoTable1583 values('=Candy,2000');
mysql> insert into DemoTable1583 values('=Lucky29,10000');
使用select语句显示表中的所有记录-mysql> select * from DemoTable1583;
这将产生以下输出-+------------------------------------------------------------+
| GameDetails |
+------------------------------------------------------------+
| =Candy,2000 |
| =Lucky29,10000 |
+------------------------------------------------------------+
2 rows in set (0.00 sec)
这是从MySQL的字段中删除部分数据的查询-mysql> update DemoTable1583 set GameDetails=replace(GameDetails,'=Candy','');
Rows matched: 2 Changed: 1 Warnings: 0
让我们再次检查表记录-mysql> select * from DemoTable1583;
这将产生以下输出-+------------------------------------------------------------+
| GameDetails |
+------------------------------------------------------------+
| ,2000 |
| =Lucky29,10000 |
+------------------------------------------------------------+
2 rows in set (0.00 sec)