update table1 a left join table2 b on a.id = b.user_id left join table3 c on a.id = c.user_idset a.phone_tel = null, b.id_code = null, c.identity_no = null, c.identity_type = nullwhere a.phone_tel = '16718787005';…
一:关联不同的表更新 1: 通过where关联更新 update student s, city c set s.province_name = c.province_name, s.city_name = c.name where s.city_code = c.code; 2:子查询更新 update student s set city_name = (select name from city where code = s.city_code); 子查询更新优化: UPDATE t_ad…
一.去重 1.查询出重复的记录 CREATE TABLE push_log_full_2013_10_30_tmp SELECT * FROM `push_log_full` WHERE time BETWEEN FROM_DAYS(TO_DAYS(NOW()) - 1) AND FROM_DAYS(TO_DAYS(NOW())) AND (imsi, andriodid, time) IN ( SELECT imsi, andriodid, time FROM `push_log_full`…
一.临时表妙用 -- 1.将老库中的mediaid和新库中的regionid对应上,然后插入到临时表中 SELECT * INTO #TempMediaRegion FROM (SELECT ww.C_MEDIA,C_ID FROM [NEWSYS].[LMSData].[dbo].Base_Region right JOIN openquery(CRM, 'select * from T_LOCREGION') ww ON C_CrmID=ww.C_REGION) hh -- 2.将媒体按媒体…