truncate table show_child; INSERT INTO show_child ( id, main_show_id, show_rules, cac_type, show_code, start_time, end_time, show_name, fee, discount, statistics_state, create_by, create_date, update_by, update_date, remarks, del_flag ) SELECT a.id, b.nid, a.showSystem, '', a.赛事编号, a.开始日期, a.结束日期, a.赛事名称, a.bmFei, a.报名优惠, '', 1, a.添加日期, 1, a.修改日期, '', a.del_tag FROM dbo.tab_games a LEFT JOIN ( SELECT 赛事地点, min(id) nid FROM dbo.tab_games GROUP BY 赛事地点 ) b ON TRIM(a.赛事地点) = b.赛事地点; update show_child set del_flag = 0 where del_flag is null; update show_child set show_rules = 0 where show_rules = '全犬种'; update show_child set show_rules = 1 where show_rules = '单独展';