update 表名 set 字段=replace(字段,‘替换的部分’,‘替换后的字符串’): update 表名 set A=replace( A, '海淀', '朝阳') where A like '海淀'; (将A字段中的“海淀”替换成“朝阳”): update yb_user_img set image=replace( image, 'http://192.168.0.126', 'http://yuebei.web66.cn');将yb_user_img表中image字段所有的“h
update (select length(t.name), t.* -- name,length(name) from g_enterprise_info t where nvl2(translate(name, '\1234567890 ', '\'), 'is characters ', 'is number ') = 'is number ' and asciistr(gszcdjh) like '%\%') set name = gszcdjh, gszcdjh =name ; 判断一
sql SELECT COUNT(字段),分组字段,SUM(字段),SUM(字段) FROM 表 GROUP BY 分组字段 java EntityWrapper<ProjectEntity> pp= new EntityWrapper<ProjectEntity>(); pp.eq("depcode", community); int proc = projectService.selectCount(pp); pp.setSqlSelect("CO
将'0654879'替换成'0754879' UPDATE dbo.SG_Functionality SET FunctionalityCode=REPLACE(FunctionalityCode,'06','07') WHERE Type=2 AND FunctionalityCode LIKE '06%'
例如student表: studentID studentName studentScore 01 Alice 90 02 Bill 95 03 Cindy 100 一.拼接多个字段的值 select studentID+‘-’+studentName+'-'+studentScore AS studentInfo from student 结果: 二.一个字段多条记录的拼接 select stuff((select '|'+studentName from student for xm
如student表: studentID studentName studentScore 01 Alice 90 02 Bill 95 03 Cindy 100 一.拼接多个字段的值 select studentID+‘-’+studentName+'-'+studentScore AS studentInfo from student 结果: 二.一个字段多条记录的拼接 select stuff((select '|'+studentName from student for xml p
最近在项目中遇到个问题,需要将表中某列字段合并成字符串输出,如果直接通过代码全部读取出来,再遍历进行拼接显然不是最好的方法,所以想着能否在数据读取的时候直接拼接好返回,网上搜了可通过for xml来实现. 首先,准备好需要的数据,脚本如下: if exists (select * from sysObjects where id=object_id('Student')) drop table Student go create table Student ( Id int, Name ) )
--更新字段为随机时间 86400秒=1天 UPDATE dl_robot ), ,GETDATE()) ) SQL存在一个表而不在另一个表中的数据 方法一 使用 not in ,容易理解,效率低 select distinct A.ID from A where A.ID not in (select ID from B) www.2cto.com 方法二 使用 left join...on... , "B.ID isnull" 表示左连接之后在B.ID 字段为
/****** Object: StoredProcedure [dbo].[getSplitValue] Script Date: 03/13/2014 13:58:12 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[getSplitValue] AS --定义获取GUID ) SET @NEWID= REPLACE(NEWID(),'-','') --判断临时表数据是否存在,如果
mysql下的将多个字段名的值复制到另一个字段名中(批量更新数据)mysql字符串拼接cancat实战例子: mysql update set 多个字段相加,如果是数字相加可以直接用+号(注:hundred,ten,one字段 为int类型):update `ssc`.`historydata` set `last3` = hundred+ten+one 如果是把几个字段的内容当成字符串拼接可以使用CONCAT函数:update `ssc`.`historydata` set `last3` =
SQL查询一个表中类别字段中Max()最大值对应的记录 SELECT A.id, A.name, A.version FROM DOC A, (SELECT id, MAX(version) AS version FROM DOC GROUP BY id) AS B WHERE A.id = B.id AND A.version = B.version