Mysql脚本将所有行复制到同一个表和其他表中

时间:2018-06-13 06:45:55

标签: mysql sql

我有两张桌子:

  • task_manager
  • key_result_area

task_manager我有一些数据,那些year_code是NULL,我必须使用更新year_code="2017-2018"复制所有行。

同时,我必须使用外键key_result_area将所有复制的数据添加到task_manager_id表中。我很难为此制作剧本。

我正在尝试这个,但它没有用。

INSERT INTO task_manager 
(employee_id, year_code,task_name, kra_flag, 
created_by,date_of_creation,date_of_modification,modified_by) 

SELECT employee_id, "2017-2018",task_name, kra_flag, 
    created_by,date_of_creation,date_of_modification,modified_by 
FROM task_manager WHERE year_code = null

样本数据: enter image description here

enter image description here

0 个答案:

没有答案