concat(),合并

instr(),过滤;INSTR()函数返回字符串中子字符串第一次出现的位置。如果在str中找不到子字符串,返回零

 

 

例如:需要将表中的两列内容合并,可以使用concat函数

update tableName set name = concat(firstName, '_', endName) where instr(name, '_') = 0;

其中

update tableName set name = concat(firstName, '_', endName)

  意思是,将name字段设置为由firstName字段和endName字段通过下换线连接起来的值;

where instr(name, '_') = 0;
  意思是,所有name字段中不包括下划线(没有合并过)的值;
  = 0,表示不包含
  > 0,表示包含,类似于 like '%_%'

  MySQL——concat / instr函数

 

 

 

 



OK.

相关文章:

  • 2021-08-23
  • 2022-02-12
  • 2021-06-26
  • 2021-11-08
猜你喜欢
  • 2021-12-02
  • 2021-06-11
  • 2021-09-06
  • 2021-11-28
  • 2022-12-23
相关资源
相似解决方案