Mysql 数据库 去除某个字段的前10个字符

时间:2022-07-22 14:55:32
表名 shop
表结构  ID   title                                         titlepic                       price                  classid
表内容  1    2013春秋肤色打底裤         /cpimg/aaa.jpg         50.00                    1

想批量去除 title字段里的 前10个字符

sql语句该怎么写?

6 个解决方案

#1


update shop set title = substring(title,10)

#2


mysql> select right('123456',length('123456')-1);
+------------------------------------+
| right('123456',length('123456')-1) |
+------------------------------------+
| 23456                              |
+------------------------------------+
1 row in set (0.00 sec)

#3


SET @A='2013春秋肤色打底裤';
SELECT SUBSTRING(@A,10+1) ;
SELECT RIGHT(@A,CHAR_LENGTH(@A)-10);
/*SUBSTRING(@A,10+1)  
--------------------
裤               
RIGHT(@A,CHAR_LENGTH(@A)-10)  
------------------------------
裤                           
*/

#4




SELECT replace('123456789123456789',SUBSTR('123456789123456789',1,10),'')

#5


mysql> select substring('12345678901234567890',11);

+--------------------------------------+
| substring('12345678901234567890',11) |
+--------------------------------------+
| 1234567890                           |
+--------------------------------------+
1 row in set (0.00 sec)

#6


update shop set title = substring(title,11);

#1


update shop set title = substring(title,10)

#2


mysql> select right('123456',length('123456')-1);
+------------------------------------+
| right('123456',length('123456')-1) |
+------------------------------------+
| 23456                              |
+------------------------------------+
1 row in set (0.00 sec)

#3


SET @A='2013春秋肤色打底裤';
SELECT SUBSTRING(@A,10+1) ;
SELECT RIGHT(@A,CHAR_LENGTH(@A)-10);
/*SUBSTRING(@A,10+1)  
--------------------
裤               
RIGHT(@A,CHAR_LENGTH(@A)-10)  
------------------------------
裤                           
*/

#4




SELECT replace('123456789123456789',SUBSTR('123456789123456789',1,10),'')

#5


mysql> select substring('12345678901234567890',11);

+--------------------------------------+
| substring('12345678901234567890',11) |
+--------------------------------------+
| 1234567890                           |
+--------------------------------------+
1 row in set (0.00 sec)

#6


update shop set title = substring(title,11);