让我们首先创建一个表-
create table DemoTable ( Download varchar(100) );
使用插入命令在表中插入一些记录-
insert into DemoTable values('120 Gigabytes'); insert into DemoTable values('190 Gigabytes'); insert into DemoTable values('250 Gigabytes'); insert into DemoTable values('1000 Gigabytes');
使用select语句显示表中的所有记录-
select *from DemoTable;
这将产生以下输出-
+----------------+ | Download | +----------------+ | 120 Gigabytes | | 190 Gigabytes | | 250 Gigabytes | | 1000 Gigabytes | +----------------+ 4 rows in set (0.00 sec)
以下是更新现有列数据并删除最后一个字符串的查询-
update DemoTable set Download=LEFT(Download, INSTR(Download, ' ') - 1); Rows matched: 4 Changed: 4 Warnings: 0
让我们再次检查表记录-
select *from DemoTable;
这将产生以下输出-
+----------+ | Download | +----------+ | 120 | | 190 | | 250 | | 1000 | +----------+ 4 rows in set (0.00 sec)