现在的位置: 首页 > 综合 > 正文

更新/新增 SQL

2011年10月08日 ⁄ 综合 ⁄ 共 663字 ⁄ 字号 评论关闭

update idc_position a,
(select positionid from equipment_position ) b   set a.status=2 where a.id=b.positionid

 

update equipment_position t1,
(select b.cicode,a.id from equipment_position a,t_device b where a.configitemid=2 and a.equipmentid=b.id) t2
set t1.cicode=t2.cicode where t1.id=t2.id

 

INSERT INTO business (Uid, ParentUid, LValue, RValue, Depth, TreeId, ChineseName, DepartmentId
, Description, ProductCode, ProductName, ProductDeptOaId, State, Id, Flag )
SELECT T1.CICode, '', 0, 0, T1.ServiceType, 0, T1.Name, T1.dep_id
, T1.Description, T1.ProductCode, T1.ProductName, T1.ProductDeptOaId, T1.State, T1.Id, 1
FROM s_service T1 LEFT JOIN s_x_sd T2 ON T2.ServiceIDRight = T1.Id AND T2.RelationType=1
WHERE  T1.ServiceType=1;

--注意字段一定要对应

抱歉!评论已关闭.