让我们首先创建一个表-
mysql> create table DemoTable1897 ( Name varchar(20) );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1897 values('john'); mysql> insert into DemoTable1897 values('Chris'); mysql> insert into DemoTable1897 values('jace'); mysql> insert into DemoTable1897 values('David'); mysql> insert into DemoTable1897 values('Chris');
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1897;
这将产生以下输出-
+-------+ | Name | +-------+ | john | | Chris | | jace | | David | | Chris | +-------+ 5 rows in set (0.00 sec)
这是获取字段值并将特定字符转换为大写字母p的查询
mysql> select replace(Name,'j','J') from DemoTable1897;
这将产生以下输出-
+-----------------------+ | replace(Name,'j','J') | +-----------------------+ | John | | Chris | | Jace | | David | | Chris | +-----------------------+ 5 rows in set (0.00 sec)