I have two tables listed below:
Table: "wp_topic"
Table: "wp_default_topics"
What i am trying to do is copy all of the rows from wp_default_topics (except for ID) to wp_topic auto-increment from the new table (wp_default_topics).
I can use the below code to copy everything fine:
INSERT INTO wp_topic SELECT * FROM wp_default_topics
but i will end up wit the error "#1062 - Duplicate entry '28' for key 'PRIMARY'"
I have tried:
INSERT INTO wp_topic SELECT * FROM wp_default_topics ON DUPLICATE KEY UPDATE ID=VALUES(ID+1)
But end up with the error message:
"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+1)' at line 1"
and i have tried:
INSERT INTO wp_topic SELECT * FROM wp_default_topics ON DUPLICATE KEY UPDATE LAST_INSERT_ID(wp_topic.ID)
But i end up with the error message:
"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(wp_topic.ID)' at line 1"
I have also tried the below which i thought would work but unfortunately it does not.
INSERT INTO wp_topic SELECT (user_id, name, subject, company, date) FROM wp_default_topics
"#1241 - Operand should contain 1 column(s)"
I have tried a few variations of the above but without any luck could i get a pointer as to what i am missing here?
Thank You
David