· 9 years ago · Nov 30, 2016, 04:44 PM
1drop table if exists tmp_goals;
2CREATE TABLE `tmp_goals` (
3 `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
4 id_old int(10),
5 `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
6 `is_active` tinyint(1) NOT NULL,
7 `is_locked` tinyint(1) NOT NULL,
8 PRIMARY KEY (`id`)
9 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
10
11insert into tmp_goals
12select null, g.id, g.name, g.is_active, g.is_locked from goal_group_items ggi, employee_goal_groups gg, goals g
13where ggi.goal_id<=1195 and ggi.goal_group_id=gg.goal_group_id and gg.valuation_cycle_id=2
14and ggi.goal_id=g.id group by g.id;
15
16select * from tmp_goals;
17
18insert into goals select null, name, is_active, is_locked from tmp_goals;
19
20update tmp_goals set id=id+1986;