我有这些表(编辑了不相关的字段)
mysql> desc studentcourseplan;
+-------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+----------------+
| cpl_id | int(11) | NO | PRI | NULL | auto_increment |
| student_id | int(11) | YES | MUL | NULL | |
+-------------------+--------------+------+-----+---------+----------------+
mysql> desc studentdates;
+-----------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+---------+------+-----+---------+----------------+
| student_date_id | int(11) | NO | PRI | NULL | auto_increment |
| student_id | int(11) | YES | | NULL | |
| student_date_cpl_id | int(11) | YES | | NULL | |
+-----------------------+---------+------+-----+---------+----------------+
我想将该列复制studentcourseplan.cpl_id
到studentdates.student_date_cpl_id
使用以下查询(以排除重复项)
SELECT cpl_id FROM studentcourseplan
WHERE student_id NOT IN ('50', '51', '85', '86', '90', '95', '89', '91', '92', '93', '94', '97', '98', '99', '100', '88')
当我执行正常操作INSERT INTO studentdates.student_date_cpl_id SELECT ......
时,它会添加到新行中,并且不会更新当前行。我将如何实现这一目标?