MySQL——concat / instr函数

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 '%_%'

  



OK.
原文地址:https://www.cnblogs.com/zuichao/p/13402493.html