使用INSERT()来自MySQL的函数。它具有以下参数-参数描述力量要修改的字符串
位置插入str2的位置
数要替换的字符数
str2要插入str的字符串
让我们首先创建一个表-mysql> create table DemoTable
-> (
-> Code varchar(100)
-> );
使用插入命令在表中插入一些记录-mysql> insert into DemoTable values('958575/98') ;
mysql> insert into DemoTable values('765432/99');
mysql> insert into DemoTable values('983456/91');
使用select语句显示表中的所有记录-mysql> select *from DemoTable;
输出结果
这将产生以下输出-+-----------+
| Code |
+-----------+
| 958575/98 |
| 765432/99 |
| 983456/91 |
+-----------+
3 rows in set (0.00 sec)
这是使用数字在varchar列上搜索的查询-mysql> select *from DemoTable where Code =INSERT(76543299,7,0,'/');
输出结果
这将产生以下输出-+-----------+
| Code |
+-----------+
| 765432/99 |
+-----------+
1 row in set (0.00 sec)