I have these tables (edited out irelevant fields)
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 | |
+-----------------------+---------+------+-----+---------+----------------+
I would like to copy the column studentcourseplan.cpl_id
to studentdates.student_date_cpl_id
using the below query (to exclude duplicates)
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')
When I do a normal INSERT INTO studentdates.student_date_cpl_id SELECT ......
it adds to new rows, and does not update the current rows. How would I achieve this?