MySQL在查询或者更新数据的时候,有字符串函数可用。

截取字符串函数:substring、instr

用法如下:

update `table` set field5 = SUBSTRING(field5  , 1 , INSTR( field5 ,'-')-1) where id = 1; //这里,要从field5里面最开始一直截取到‘-’的地方(不包括‘-’)。注意,substring是从1开始,而不是一般的程序函数从0开始。

 

 

 

字符串链接函数:contact

用法如下:

update `table` set field5 = concact(field5  , 'somestr') where id = 1; //这里,要吧field5和‘somestr’链接起来,再更新到field5

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-23
  • 2022-12-23
  • 2021-07-19
相关资源
相似解决方案